Skip to content

Commit

Permalink
Rollup merge of #69766 - skade:make-point-copy-in-add-documentation, …
Browse files Browse the repository at this point in the history
…r=shepmaster

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.
  • Loading branch information
Centril authored Mar 11, 2020
2 parents ae12272 + 69aaed8 commit 452c147
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/libcore/ops/arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/// ```
/// use std::ops::Add;
///
/// #[derive(Debug, PartialEq)]
/// #[derive(Debug, Copy, Clone, PartialEq)]
/// struct Point {
/// x: i32,
/// y: i32,
Expand Down Expand Up @@ -42,7 +42,7 @@
/// ```
/// use std::ops::Add;
///
/// #[derive(Debug, PartialEq)]
/// #[derive(Debug, Copy, Clone, PartialEq)]
/// struct Point<T> {
/// x: T,
/// y: T,
Expand Down Expand Up @@ -115,7 +115,7 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
/// ```
/// use std::ops::Sub;
///
/// #[derive(Debug, PartialEq)]
/// #[derive(Debug, Copy, Clone, PartialEq)]
/// struct Point {
/// x: i32,
/// y: i32,
Expand Down Expand Up @@ -657,7 +657,7 @@ neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 }
/// ```
/// use std::ops::AddAssign;
///
/// #[derive(Debug, PartialEq)]
/// #[derive(Debug, Copy, Clone, PartialEq)]
/// struct Point {
/// x: i32,
/// y: i32,
Expand Down Expand Up @@ -715,7 +715,7 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
/// ```
/// use std::ops::SubAssign;
///
/// #[derive(Debug, PartialEq)]
/// #[derive(Debug, Copy, Clone, PartialEq)]
/// struct Point {
/// x: i32,
/// y: i32,
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
//! ```rust
//! use std::ops::{Add, Sub};
//!
//! #[derive(Debug, PartialEq)]
//! #[derive(Debug, Copy, Clone, PartialEq)]
//! struct Point {
//! x: i32,
//! y: i32,
Expand Down

0 comments on commit 452c147

Please sign in to comment.