diff options
| author | Matthew Piziak <matthew.piziak@gmail.com> | 2016-08-18 15:10:57 -0400 |
|---|---|---|
| committer | Matthew Piziak <matthew.piziak@gmail.com> | 2016-08-29 11:24:22 -0400 |
| commit | 89f7e9269826abf44ee39fdde06197aff15f30ff (patch) | |
| tree | 28e628c7a91eee4231444b981864ab1024aaa5a6 | |
| parent | 528c6f3ed6a23a374dc5a40582d1bea2f2cfda65 (diff) | |
| download | rust-89f7e9269826abf44ee39fdde06197aff15f30ff.tar.gz rust-89f7e9269826abf44ee39fdde06197aff15f30ff.zip | |
demonstrate `RHS != Self` use cases for `Add` and `Sub`
remove extra `../`s
| -rw-r--r-- | src/libcore/ops.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 5d431230e97..78c8fc0ac45 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<Duration>`, 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<RHS=Self> { @@ -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<Duration>`, 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<RHS=Self> { |
