Skip to content

Commit

Permalink
Fix doc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron committed Aug 30, 2024
1 parent cf4d555 commit fda192d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions impl/doc/add.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<MixedInts, derive_more::BinaryError>;
fn add(self, rhs: MixedInts) -> Result<MixedInts, derive_more::BinaryError> {
match (self, rhs) {
Expand Down
4 changes: 2 additions & 2 deletions impl/doc/add_assign.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions impl/doc/display.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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; }
#
Expand Down
2 changes: 1 addition & 1 deletion impl/doc/sum.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.fold(
Expand Down
42 changes: 21 additions & 21 deletions impl/doc/try_into.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,48 +95,48 @@ Code like this will be generated:
# UnsignedOne(u32),
# UnsignedTwo(u32),
# }
impl derive_more::TryFrom<MixedInts> for (i32) {
type Error = &'static str;
impl TryFrom<MixedInts> for (i32) {
type Error = derive_more::TryIntoError<MixedInts>;
fn try_from(value: MixedInts) -> Result<Self, Self::Error> {
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<MixedInts> for (i64) {
type Error = &'static str;
impl TryFrom<MixedInts> for (i64) {
type Error = derive_more::TryIntoError<MixedInts>;
fn try_from(value: MixedInts) -> Result<Self, Self::Error> {
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<MixedInts> for (i32, i32) {
type Error = &'static str;
impl TryFrom<MixedInts> for (i32, i32) {
type Error = derive_more::TryIntoError<MixedInts>;
fn try_from(value: MixedInts) -> Result<Self, Self::Error> {
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<MixedInts> for (i64, i64) {
type Error = &'static str;
impl TryFrom<MixedInts> for (i64, i64) {
type Error = derive_more::TryIntoError<MixedInts>;
fn try_from(value: MixedInts) -> Result<Self, Self::Error> {
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<MixedInts> for (u32) {
type Error = &'static str;
impl TryFrom<MixedInts> for (u32) {
type Error = derive_more::TryIntoError<MixedInts>;
fn try_from(value: MixedInts) -> Result<Self, Self::Error> {
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")),
}
}
}
Expand All @@ -161,21 +161,21 @@ Code like this will be generated:
# SmallInt(i32),
# Unit,
# }
impl derive_more::TryFrom<EnumWithUnit> for (i32) {
type Error = &'static str;
impl TryFrom<EnumWithUnit> for (i32) {
type Error = derive_more::TryIntoError<EnumWithUnit>;
fn try_from(value: EnumWithUnit) -> Result<Self, Self::Error> {
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<EnumWithUnit> for () {
type Error = &'static str;
impl TryFrom<EnumWithUnit> for () {
type Error = derive_more::TryIntoError<EnumWithUnit>;
fn try_from(value: EnumWithUnit) -> Result<Self, Self::Error> {
match value {
EnumWithUnit::Unit => Ok(()),
_ => Err("Only Unit can be converted to ()"),
_ => Err(derive_more::TryIntoError::new(value, "Unit", "()")),
}
}
}
Expand Down

0 comments on commit fda192d

Please sign in to comment.