From fda192db185027bf0fb0a6aeb385c0e8d88f7b34 Mon Sep 17 00:00:00 2001 From: tyranron Date: Fri, 30 Aug 2024 03:07:26 +0300 Subject: [PATCH] Fix doc tests --- impl/doc/add.md | 6 +++--- impl/doc/add_assign.md | 4 ++-- impl/doc/display.md | 4 ++-- impl/doc/sum.md | 2 +- impl/doc/try_into.md | 42 +++++++++++++++++++++--------------------- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/impl/doc/add.md b/impl/doc/add.md index ad709385..5f8e12ad 100644 --- a/impl/doc/add.md +++ b/impl/doc/add.md @@ -26,7 +26,7 @@ Code like this will be generated: ```rust # struct MyInts(i32, i32); -impl derive_more::Add for MyInts { +impl derive_more::core::ops::Add for MyInts { type Output = MyInts; fn add(self, rhs: MyInts) -> MyInts { MyInts(self.0.add(rhs.0), self.1.add(rhs.1)) @@ -60,7 +60,7 @@ Code like this will be generated: # x: i32, # y: i32, # } -impl derive_more::Add for Point2D { +impl derive_more::core::ops::Add for Point2D { type Output = Point2D; fn add(self, rhs: Point2D) -> Point2D { Point2D { @@ -112,7 +112,7 @@ Code like this will be generated: # UnsignedTwo(u32), # Unit, # } -impl derive_more::Add for MixedInts { +impl derive_more::core::ops::Add for MixedInts { type Output = Result; fn add(self, rhs: MixedInts) -> Result { match (self, rhs) { diff --git a/impl/doc/add_assign.md b/impl/doc/add_assign.md index 4eab9aad..d52fe252 100644 --- a/impl/doc/add_assign.md +++ b/impl/doc/add_assign.md @@ -22,7 +22,7 @@ Code like this will be generated: ```rust # struct MyInts(i32, i32); -impl derive_more::AddAssign for MyInts { +impl derive_more::core::ops::AddAssign for MyInts { fn add_assign(&mut self, rhs: MyInts) { self.0.add_assign(rhs.0); self.1.add_assign(rhs.1); @@ -56,7 +56,7 @@ Code like this will be generated: # x: i32, # y: i32, # } -impl derive_more::AddAssign for Point2D { +impl derive_more::core::ops::AddAssign for Point2D { fn add_assign(&mut self, rhs: Point2D) { self.x.add_assign(rhs.x); self.y.add_assign(rhs.y); diff --git a/impl/doc/display.md b/impl/doc/display.md index 211ffced..0bdf3425 100644 --- a/impl/doc/display.md +++ b/impl/doc/display.md @@ -33,7 +33,7 @@ once to get the address of the field itself, instead of the address of the reference to the field: ```rust -# use derive_more::Display; +# use derive_more::with_trait::Display; # #[derive(Display)] #[display("{field:p} {:p}", *field)] @@ -107,7 +107,7 @@ Explicitly specified bounds are added to the inferred ones. Note how no `V: Disp because it's inferred already. ```rust -# use derive_more::Display; +# use derive_more::with_trait::Display; # # trait MyTrait { fn my_function(&self) -> i32; } # diff --git a/impl/doc/sum.md b/impl/doc/sum.md index 8219c55f..0a23314a 100644 --- a/impl/doc/sum.md +++ b/impl/doc/sum.md @@ -51,7 +51,7 @@ Code like this will be generated for the `Sum` implementation: # MyInts(self.0.add(rhs.0), self.1.add(rhs.1)) # } # } -impl derive_more::Sum for MyInts { +impl derive_more::core::ops::Sum for MyInts { #[inline] fn sum>(iter: I) -> Self { iter.fold( diff --git a/impl/doc/try_into.md b/impl/doc/try_into.md index 3953fbf7..c2ea7c38 100644 --- a/impl/doc/try_into.md +++ b/impl/doc/try_into.md @@ -95,48 +95,48 @@ Code like this will be generated: # UnsignedOne(u32), # UnsignedTwo(u32), # } -impl derive_more::TryFrom for (i32) { - type Error = &'static str; +impl TryFrom for (i32) { + type Error = derive_more::TryIntoError; fn try_from(value: MixedInts) -> Result { match value { MixedInts::SmallInt(__0) => Ok(__0), - _ => Err("Only SmallInt can be converted to i32"), + _ => Err(derive_more::TryIntoError::new(value, "SmallInt", "i32")), } } } -impl derive_more::TryFrom for (i64) { - type Error = &'static str; +impl TryFrom for (i64) { + type Error = derive_more::TryIntoError; fn try_from(value: MixedInts) -> Result { match value { MixedInts::BigInt(__0) => Ok(__0), - _ => Err("Only BigInt can be converted to i64"), + _ => Err(derive_more::TryIntoError::new(value, "BigInt", "i64")), } } } -impl derive_more::TryFrom for (i32, i32) { - type Error = &'static str; +impl TryFrom for (i32, i32) { + type Error = derive_more::TryIntoError; fn try_from(value: MixedInts) -> Result { match value { MixedInts::TwoSmallInts(__0, __1) => Ok((__0, __1)), - _ => Err("Only TwoSmallInts can be converted to (i32, i32)"), + _ => Err(derive_more::TryIntoError::new(value, "TwoSmallInts", "(i32, i32)")), } } } -impl derive_more::TryFrom for (i64, i64) { - type Error = &'static str; +impl TryFrom for (i64, i64) { + type Error = derive_more::TryIntoError; fn try_from(value: MixedInts) -> Result { match value { MixedInts::NamedSmallInts { x: __0, y: __1 } => Ok((__0, __1)), - _ => Err("Only NamedSmallInts can be converted to (i64, i64)"), + _ => Err(derive_more::TryIntoError::new(value, "NamedSmallInts", "(i64, i64)")), } } } -impl derive_more::TryFrom for (u32) { - type Error = &'static str; +impl TryFrom for (u32) { + type Error = derive_more::TryIntoError; fn try_from(value: MixedInts) -> Result { match value { MixedInts::UnsignedOne(__0) | MixedInts::UnsignedTwo(__0) => Ok(__0), - _ => Err("Only UnsignedOne, UnsignedTwo can be converted to u32"), + _ => Err(derive_more::TryIntoError::new(value, "UnsignedOne", "u32")), } } } @@ -161,21 +161,21 @@ Code like this will be generated: # SmallInt(i32), # Unit, # } -impl derive_more::TryFrom for (i32) { - type Error = &'static str; +impl TryFrom for (i32) { + type Error = derive_more::TryIntoError; fn try_from(value: EnumWithUnit) -> Result { match value { EnumWithUnit::SmallInt(__0) => Ok(__0), - _ => Err("Only SmallInt can be converted to i32"), + _ => Err(derive_more::TryIntoError::new(value, "SmallInt", "i32")), } } } -impl derive_more::TryFrom for () { - type Error = &'static str; +impl TryFrom for () { + type Error = derive_more::TryIntoError; fn try_from(value: EnumWithUnit) -> Result { match value { EnumWithUnit::Unit => Ok(()), - _ => Err("Only Unit can be converted to ()"), + _ => Err(derive_more::TryIntoError::new(value, "Unit", "()")), } } }