From 89f7e9269826abf44ee39fdde06197aff15f30ff Mon Sep 17 00:00:00 2001 From: Matthew Piziak Date: Thu, 18 Aug 2016 15:10:57 -0400 Subject: [PATCH 1/2] demonstrate `RHS != Self` use cases for `Add` and `Sub` remove extra `../`s --- src/libcore/ops.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 5d431230e9744..78c8fc0ac4549 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -212,6 +212,12 @@ macro_rules! forward_ref_binop { /// Point { x: 3, y: 3 }); /// } /// ``` +/// +/// Note that `RHS = Self` by default, but this is not mandatory. For example, +/// [std::time::SystemTime] implements `Add`, which permits +/// operations of the form `SystemTime = SystemTime + Duration`. +/// +/// [std::time::SystemTime]: ../time/struct.SystemTime.html #[lang = "add"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Add { @@ -279,6 +285,12 @@ add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// Point { x: 1, y: 0 }); /// } /// ``` +/// +/// Note that `RHS = Self` by default, but this is not mandatory. For example, +/// [std::time::SystemTime] implements `Sub`, which permits +/// operations of the form `SystemTime = SystemTime - Duration`. +/// +/// [std::time::SystemTime]: ../time/struct.SystemTime.html #[lang = "sub"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Sub { From 9a400f0a313c765ed8a39d0863321ff9e88d8961 Mon Sep 17 00:00:00 2001 From: Matthew Piziak Date: Wed, 31 Aug 2016 18:17:44 -0400 Subject: [PATCH 2/2] replace `../` with `../../std/` to support `core` docs --- src/libcore/ops.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 78c8fc0ac4549..e36539bf17d57 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -217,7 +217,7 @@ macro_rules! forward_ref_binop { /// [std::time::SystemTime] implements `Add`, which permits /// operations of the form `SystemTime = SystemTime + Duration`. /// -/// [std::time::SystemTime]: ../time/struct.SystemTime.html +/// [std::time::SystemTime]: ../../std/time/struct.SystemTime.html #[lang = "add"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Add { @@ -290,7 +290,7 @@ add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// [std::time::SystemTime] implements `Sub`, which permits /// operations of the form `SystemTime = SystemTime - Duration`. /// -/// [std::time::SystemTime]: ../time/struct.SystemTime.html +/// [std::time::SystemTime]: ../../std/time/struct.SystemTime.html #[lang = "sub"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Sub {