Skip to content

Commit 89f7e92

Browse files
demonstrate RHS != Self use cases for Add and Sub
remove extra `../`s
1 parent 528c6f3 commit 89f7e92

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/libcore/ops.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ macro_rules! forward_ref_binop {
212212
/// Point { x: 3, y: 3 });
213213
/// }
214214
/// ```
215+
///
216+
/// Note that `RHS = Self` by default, but this is not mandatory. For example,
217+
/// [std::time::SystemTime] implements `Add<Duration>`, which permits
218+
/// operations of the form `SystemTime = SystemTime + Duration`.
219+
///
220+
/// [std::time::SystemTime]: ../time/struct.SystemTime.html
215221
#[lang = "add"]
216222
#[stable(feature = "rust1", since = "1.0.0")]
217223
pub trait Add<RHS=Self> {
@@ -279,6 +285,12 @@ add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
279285
/// Point { x: 1, y: 0 });
280286
/// }
281287
/// ```
288+
///
289+
/// Note that `RHS = Self` by default, but this is not mandatory. For example,
290+
/// [std::time::SystemTime] implements `Sub<Duration>`, which permits
291+
/// operations of the form `SystemTime = SystemTime - Duration`.
292+
///
293+
/// [std::time::SystemTime]: ../time/struct.SystemTime.html
282294
#[lang = "sub"]
283295
#[stable(feature = "rust1", since = "1.0.0")]
284296
pub trait Sub<RHS=Self> {

0 commit comments

Comments
 (0)