From 69aaed872cec119b1034c52151d00fb5308e7407 Mon Sep 17 00:00:00 2001 From: Florian Gilcher Date: Fri, 6 Mar 2020 10:37:23 +0100 Subject: [PATCH] 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 --- src/libcore/ops/arith.rs | 10 +++++----- src/libcore/ops/mod.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 59a72799e2567..e9ec81394e32d 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -13,7 +13,7 @@ /// ``` /// use std::ops::Add; /// -/// #[derive(Debug, PartialEq)] +/// #[derive(Debug, Copy, Clone, PartialEq)] /// struct Point { /// x: i32, /// y: i32, @@ -42,7 +42,7 @@ /// ``` /// use std::ops::Add; /// -/// #[derive(Debug, PartialEq)] +/// #[derive(Debug, Copy, Clone, PartialEq)] /// struct Point { /// x: T, /// y: T, @@ -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, @@ -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, @@ -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, diff --git a/src/libcore/ops/mod.rs b/src/libcore/ops/mod.rs index 77b92b6ccbdaa..e3e5934b44be1 100644 --- a/src/libcore/ops/mod.rs +++ b/src/libcore/ops/mod.rs @@ -42,7 +42,7 @@ //! ```rust //! use std::ops::{Add, Sub}; //! -//! #[derive(Debug, PartialEq)] +//! #[derive(Debug, Copy, Clone, PartialEq)] //! struct Point { //! x: i32, //! y: i32,