Skip to content

Commit 69aaed8

Browse files
skadeshepmaster
andcommitted
Make Point Copy in arithmetic documentation
Small composite types like `Point { x: i32, y: i32}` are plain old data and we should encourage users to derive `Copy` on them. This changes the semantics of the edited examples slightly: instead of consuming the operands during addition, it will copy them. This is desired behaviour. Co-Authored-By: Jake Goulding <[email protected]>
1 parent 4a1b69d commit 69aaed8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/libcore/ops/arith.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/// ```
1414
/// use std::ops::Add;
1515
///
16-
/// #[derive(Debug, PartialEq)]
16+
/// #[derive(Debug, Copy, Clone, PartialEq)]
1717
/// struct Point {
1818
/// x: i32,
1919
/// y: i32,
@@ -42,7 +42,7 @@
4242
/// ```
4343
/// use std::ops::Add;
4444
///
45-
/// #[derive(Debug, PartialEq)]
45+
/// #[derive(Debug, Copy, Clone, PartialEq)]
4646
/// struct Point<T> {
4747
/// x: T,
4848
/// y: T,
@@ -115,7 +115,7 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
115115
/// ```
116116
/// use std::ops::Sub;
117117
///
118-
/// #[derive(Debug, PartialEq)]
118+
/// #[derive(Debug, Copy, Clone, PartialEq)]
119119
/// struct Point {
120120
/// x: i32,
121121
/// y: i32,
@@ -657,7 +657,7 @@ neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 }
657657
/// ```
658658
/// use std::ops::AddAssign;
659659
///
660-
/// #[derive(Debug, PartialEq)]
660+
/// #[derive(Debug, Copy, Clone, PartialEq)]
661661
/// struct Point {
662662
/// x: i32,
663663
/// y: i32,
@@ -715,7 +715,7 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
715715
/// ```
716716
/// use std::ops::SubAssign;
717717
///
718-
/// #[derive(Debug, PartialEq)]
718+
/// #[derive(Debug, Copy, Clone, PartialEq)]
719719
/// struct Point {
720720
/// x: i32,
721721
/// y: i32,

src/libcore/ops/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
//! ```rust
4343
//! use std::ops::{Add, Sub};
4444
//!
45-
//! #[derive(Debug, PartialEq)]
45+
//! #[derive(Debug, Copy, Clone, PartialEq)]
4646
//! struct Point {
4747
//! x: i32,
4848
//! y: i32,

0 commit comments

Comments
 (0)