Trait grafix_toolbox::uses::ops::Add 1.0.0[−][src]
Expand description
The addition operator +.
Note that Rhs is 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.
Examples
Addable points
use std::ops::Add; #[derive(Debug, Copy, Clone, PartialEq)] struct Point { x: i32, y: i32, } impl Add for Point { type Output = Self; fn add(self, other: Self) -> Self { Self { x: self.x + other.x, y: self.y + other.y, } } } assert_eq!(Point { x: 1, y: 0 } + Point { x: 2, y: 3 }, Point { x: 3, y: 3 });
Implementing Add with generics
Here is an example of the same Point struct implementing the Add trait
using generics.
use std::ops::Add; #[derive(Debug, Copy, Clone, PartialEq)] struct Point<T> { x: T, y: T, } // Notice that the implementation uses the associated type `Output`. impl<T: Add<Output = T>> Add for Point<T> { type Output = Self; fn add(self, other: Self) -> Self::Output { Self { x: self.x + other.x, y: self.y + other.y, } } } assert_eq!(Point { x: 1, y: 0 } + Point { x: 2, y: 3 }, Point { x: 3, y: 3 });
Associated Types
Required methods
Implementations on Foreign Types
Implements the + operator for concatenating two strings.
This consumes the String on the left-hand side and re-uses its buffer (growing it if
necessary). This is done to avoid allocating a new String and copying the entire contents on
every operation, which would lead to O(n^2) running time when building an n-byte string by
repeated concatenation.
The string on the right-hand side is only borrowed; its contents are copied into the returned
String.
Examples
Concatenating two Strings takes the first by value and borrows the second:
let a = String::from("hello"); let b = String::from(" world"); let c = a + &b; // `a` is moved and can no longer be used here.
If you want to keep using the first String, you can clone it and append to the clone instead:
let a = String::from("hello"); let b = String::from(" world"); let c = a.clone() + &b; // `a` is still valid here.
Concatenating &str slices can be done by converting the first to a String:
let a = "hello"; let b = " world"; let c = a.to_string() + b;
impl Add<Point> for Point
impl Add<Point> for Pointimpl<'a, 'b, T, R1, C1, R2, C2, SA, SB> Add<&'b Matrix<T, R2, C2, SB>> for &'a Matrix<T, R1, C1, SA> where
T: Scalar + ClosedAdd<T>,
C2: Dim,
R1: Dim,
R2: Dim,
C1: Dim,
SA: Storage<T, R1, C1>,
SB: Storage<T, R2, C2>,
DefaultAllocator: SameShapeAllocator<T, R1, C1, R2, C2>,
ShapeConstraint: SameNumberOfRows<R1, R2>,
ShapeConstraint: SameNumberOfColumns<C1, C2>, [src]
impl<'a, 'b, T, R1, C1, R2, C2, SA, SB> Add<&'b Matrix<T, R2, C2, SB>> for &'a Matrix<T, R1, C1, SA> where
T: Scalar + ClosedAdd<T>,
C2: Dim,
R1: Dim,
R2: Dim,
C1: Dim,
SA: Storage<T, R1, C1>,
SB: Storage<T, R2, C2>,
DefaultAllocator: SameShapeAllocator<T, R1, C1, R2, C2>,
ShapeConstraint: SameNumberOfRows<R1, R2>,
ShapeConstraint: SameNumberOfColumns<C1, C2>, [src]type Output = Matrix<T, <ShapeConstraint as SameNumberOfRows<R1, R2>>::Representative, <ShapeConstraint as SameNumberOfColumns<C1, C2>>::Representative, <DefaultAllocator as Allocator<T, <ShapeConstraint as SameNumberOfRows<R1, R2>>::Representative, <ShapeConstraint as SameNumberOfColumns<C1, C2>>::Representative>>::Buffer>impl<'a, T, R1, C1, R2, C2, SA, SB> Add<Matrix<T, R2, C2, SB>> for &'a Matrix<T, R1, C1, SA> where
T: Scalar + ClosedAdd<T>,
C2: Dim,
R1: Dim,
R2: Dim,
C1: Dim,
SA: Storage<T, R1, C1>,
SB: Storage<T, R2, C2>,
DefaultAllocator: SameShapeAllocator<T, R2, C2, R1, C1>,
ShapeConstraint: SameNumberOfRows<R2, R1>,
ShapeConstraint: SameNumberOfColumns<C2, C1>, [src]
impl<'a, T, R1, C1, R2, C2, SA, SB> Add<Matrix<T, R2, C2, SB>> for &'a Matrix<T, R1, C1, SA> where
T: Scalar + ClosedAdd<T>,
C2: Dim,
R1: Dim,
R2: Dim,
C1: Dim,
SA: Storage<T, R1, C1>,
SB: Storage<T, R2, C2>,
DefaultAllocator: SameShapeAllocator<T, R2, C2, R1, C1>,
ShapeConstraint: SameNumberOfRows<R2, R1>,
ShapeConstraint: SameNumberOfColumns<C2, C1>, [src]type Output = Matrix<T, <ShapeConstraint as SameNumberOfRows<R2, R1>>::Representative, <ShapeConstraint as SameNumberOfColumns<C2, C1>>::Representative, <DefaultAllocator as Allocator<T, <ShapeConstraint as SameNumberOfRows<R2, R1>>::Representative, <ShapeConstraint as SameNumberOfColumns<C2, C1>>::Representative>>::Buffer>impl<T> Add<Quaternion<T>> for Quaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]
impl<T> Add<Quaternion<T>> for Quaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]type Output = Quaternion<T>impl<'a, T> Add<Quaternion<T>> for &'a Quaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]
impl<'a, T> Add<Quaternion<T>> for &'a Quaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]type Output = Quaternion<T>impl<'b, T, R1, C1, R2, C2, SA, SB> Add<&'b Matrix<T, R2, C2, SB>> for Matrix<T, R1, C1, SA> where
T: Scalar + ClosedAdd<T>,
C2: Dim,
R1: Dim,
R2: Dim,
C1: Dim,
SA: Storage<T, R1, C1>,
SB: Storage<T, R2, C2>,
DefaultAllocator: SameShapeAllocator<T, R1, C1, R2, C2>,
ShapeConstraint: SameNumberOfRows<R1, R2>,
ShapeConstraint: SameNumberOfColumns<C1, C2>, [src]
impl<'b, T, R1, C1, R2, C2, SA, SB> Add<&'b Matrix<T, R2, C2, SB>> for Matrix<T, R1, C1, SA> where
T: Scalar + ClosedAdd<T>,
C2: Dim,
R1: Dim,
R2: Dim,
C1: Dim,
SA: Storage<T, R1, C1>,
SB: Storage<T, R2, C2>,
DefaultAllocator: SameShapeAllocator<T, R1, C1, R2, C2>,
ShapeConstraint: SameNumberOfRows<R1, R2>,
ShapeConstraint: SameNumberOfColumns<C1, C2>, [src]type Output = Matrix<T, <ShapeConstraint as SameNumberOfRows<R1, R2>>::Representative, <ShapeConstraint as SameNumberOfColumns<C1, C2>>::Representative, <DefaultAllocator as Allocator<T, <ShapeConstraint as SameNumberOfRows<R1, R2>>::Representative, <ShapeConstraint as SameNumberOfColumns<C1, C2>>::Representative>>::Buffer>impl<T> Add<DualQuaternion<T>> for DualQuaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]
impl<T> Add<DualQuaternion<T>> for DualQuaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]type Output = DualQuaternion<T>pub fn add(
self,
rhs: DualQuaternion<T>
) -> <DualQuaternion<T> as Add<DualQuaternion<T>>>::Output[src]impl<'a, T> Add<DualQuaternion<T>> for &'a DualQuaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]
impl<'a, T> Add<DualQuaternion<T>> for &'a DualQuaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]type Output = DualQuaternion<T>pub fn add(
self,
rhs: DualQuaternion<T>
) -> <&'a DualQuaternion<T> as Add<DualQuaternion<T>>>::Output[src]impl<T, R1, C1, R2, C2, SA, SB> Add<Matrix<T, R2, C2, SB>> for Matrix<T, R1, C1, SA> where
T: Scalar + ClosedAdd<T>,
C2: Dim,
R1: Dim,
R2: Dim,
C1: Dim,
SA: Storage<T, R1, C1>,
SB: Storage<T, R2, C2>,
DefaultAllocator: SameShapeAllocator<T, R1, C1, R2, C2>,
ShapeConstraint: SameNumberOfRows<R1, R2>,
ShapeConstraint: SameNumberOfColumns<C1, C2>, [src]
impl<T, R1, C1, R2, C2, SA, SB> Add<Matrix<T, R2, C2, SB>> for Matrix<T, R1, C1, SA> where
T: Scalar + ClosedAdd<T>,
C2: Dim,
R1: Dim,
R2: Dim,
C1: Dim,
SA: Storage<T, R1, C1>,
SB: Storage<T, R2, C2>,
DefaultAllocator: SameShapeAllocator<T, R1, C1, R2, C2>,
ShapeConstraint: SameNumberOfRows<R1, R2>,
ShapeConstraint: SameNumberOfColumns<C1, C2>, [src]type Output = Matrix<T, <ShapeConstraint as SameNumberOfRows<R1, R2>>::Representative, <ShapeConstraint as SameNumberOfColumns<C1, C2>>::Representative, <DefaultAllocator as Allocator<T, <ShapeConstraint as SameNumberOfRows<R1, R2>>::Representative, <ShapeConstraint as SameNumberOfColumns<C1, C2>>::Representative>>::Buffer>impl<'a, 'b, T, D2, SB, const D1: usize> Add<&'b Matrix<T, D2, Const<1_usize>, SB>> for &'a Point<T, D1> where
T: Scalar + ClosedAdd<T>,
D2: Dim,
SB: Storage<T, D2, Const<1_usize>>,
ShapeConstraint: SameNumberOfRows<Const<D1>, D2>,
ShapeConstraint: SameNumberOfColumns<Const<1_usize>, Const<1_usize>>,
<ShapeConstraint as SameNumberOfRows<Const<D1>, D2>>::Representative == Const<D1>,
<ShapeConstraint as SameNumberOfColumns<Const<1_usize>, Const<1_usize>>>::Representative == Const<1_usize>, [src]
impl<'a, 'b, T, D2, SB, const D1: usize> Add<&'b Matrix<T, D2, Const<1_usize>, SB>> for &'a Point<T, D1> where
T: Scalar + ClosedAdd<T>,
D2: Dim,
SB: Storage<T, D2, Const<1_usize>>,
ShapeConstraint: SameNumberOfRows<Const<D1>, D2>,
ShapeConstraint: SameNumberOfColumns<Const<1_usize>, Const<1_usize>>,
<ShapeConstraint as SameNumberOfRows<Const<D1>, D2>>::Representative == Const<D1>,
<ShapeConstraint as SameNumberOfColumns<Const<1_usize>, Const<1_usize>>>::Representative == Const<1_usize>, [src]impl<'a, 'b, T> Add<&'b DualQuaternion<T>> for &'a DualQuaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]
impl<'a, 'b, T> Add<&'b DualQuaternion<T>> for &'a DualQuaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]type Output = DualQuaternion<T>pub fn add(
self,
rhs: &'b DualQuaternion<T>
) -> <&'a DualQuaternion<T> as Add<&'b DualQuaternion<T>>>::Output[src]impl<'b, T> Add<&'b Quaternion<T>> for Quaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]
impl<'b, T> Add<&'b Quaternion<T>> for Quaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]type Output = Quaternion<T>impl<'a, 'b, T> Add<&'b Quaternion<T>> for &'a Quaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]
impl<'a, 'b, T> Add<&'b Quaternion<T>> for &'a Quaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]type Output = Quaternion<T>pub fn add(
self,
rhs: &'b Quaternion<T>
) -> <&'a Quaternion<T> as Add<&'b Quaternion<T>>>::Output[src]impl<'b, T> Add<&'b DualQuaternion<T>> for DualQuaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]
impl<'b, T> Add<&'b DualQuaternion<T>> for DualQuaternion<T> where
T: SimdRealField,
<T as SimdValue>::Element: SimdRealField, [src]type Output = DualQuaternion<T>pub fn add(
self,
rhs: &'b DualQuaternion<T>
) -> <DualQuaternion<T> as Add<&'b DualQuaternion<T>>>::Output[src]impl<'a, T, D2, SB, const D1: usize> Add<Matrix<T, D2, Const<1_usize>, SB>> for &'a Point<T, D1> where
T: Scalar + ClosedAdd<T>,
D2: Dim,
SB: Storage<T, D2, Const<1_usize>>,
ShapeConstraint: SameNumberOfRows<Const<D1>, D2>,
ShapeConstraint: SameNumberOfColumns<Const<1_usize>, Const<1_usize>>,
<ShapeConstraint as SameNumberOfRows<Const<D1>, D2>>::Representative == Const<D1>,
<ShapeConstraint as SameNumberOfColumns<Const<1_usize>, Const<1_usize>>>::Representative == Const<1_usize>, [src]
impl<'a, T, D2, SB, const D1: usize> Add<Matrix<T, D2, Const<1_usize>, SB>> for &'a Point<T, D1> where
T: Scalar + ClosedAdd<T>,
D2: Dim,
SB: Storage<T, D2, Const<1_usize>>,
ShapeConstraint: SameNumberOfRows<Const<D1>, D2>,
ShapeConstraint: SameNumberOfColumns<Const<1_usize>, Const<1_usize>>,
<ShapeConstraint as SameNumberOfRows<Const<D1>, D2>>::Representative == Const<D1>,
<ShapeConstraint as SameNumberOfColumns<Const<1_usize>, Const<1_usize>>>::Representative == Const<1_usize>, [src]impl<'b, T, D2, SB, const D1: usize> Add<&'b Matrix<T, D2, Const<1_usize>, SB>> for Point<T, D1> where
T: Scalar + ClosedAdd<T>,
D2: Dim,
SB: Storage<T, D2, Const<1_usize>>,
ShapeConstraint: SameNumberOfRows<Const<D1>, D2>,
ShapeConstraint: SameNumberOfColumns<Const<1_usize>, Const<1_usize>>,
<ShapeConstraint as SameNumberOfRows<Const<D1>, D2>>::Representative == Const<D1>,
<ShapeConstraint as SameNumberOfColumns<Const<1_usize>, Const<1_usize>>>::Representative == Const<1_usize>, [src]
impl<'b, T, D2, SB, const D1: usize> Add<&'b Matrix<T, D2, Const<1_usize>, SB>> for Point<T, D1> where
T: Scalar + ClosedAdd<T>,
D2: Dim,
SB: Storage<T, D2, Const<1_usize>>,
ShapeConstraint: SameNumberOfRows<Const<D1>, D2>,
ShapeConstraint: SameNumberOfColumns<Const<1_usize>, Const<1_usize>>,
<ShapeConstraint as SameNumberOfRows<Const<D1>, D2>>::Representative == Const<D1>,
<ShapeConstraint as SameNumberOfColumns<Const<1_usize>, Const<1_usize>>>::Representative == Const<1_usize>, [src]impl<T, D2, SB, const D1: usize> Add<Matrix<T, D2, Const<1_usize>, SB>> for Point<T, D1> where
T: Scalar + ClosedAdd<T>,
D2: Dim,
SB: Storage<T, D2, Const<1_usize>>,
ShapeConstraint: SameNumberOfRows<Const<D1>, D2>,
ShapeConstraint: SameNumberOfColumns<Const<1_usize>, Const<1_usize>>,
<ShapeConstraint as SameNumberOfRows<Const<D1>, D2>>::Representative == Const<D1>,
<ShapeConstraint as SameNumberOfColumns<Const<1_usize>, Const<1_usize>>>::Representative == Const<1_usize>, [src]
impl<T, D2, SB, const D1: usize> Add<Matrix<T, D2, Const<1_usize>, SB>> for Point<T, D1> where
T: Scalar + ClosedAdd<T>,
D2: Dim,
SB: Storage<T, D2, Const<1_usize>>,
ShapeConstraint: SameNumberOfRows<Const<D1>, D2>,
ShapeConstraint: SameNumberOfColumns<Const<1_usize>, Const<1_usize>>,
<ShapeConstraint as SameNumberOfRows<Const<D1>, D2>>::Representative == Const<D1>,
<ShapeConstraint as SameNumberOfColumns<Const<1_usize>, Const<1_usize>>>::Representative == Const<1_usize>, [src]UInt<Ul, B1> + UInt<Ur, B0> = UInt<Ul + Ur, B1>
impl<I> Add<I> for Z0 where
I: Integer,
impl<I> Add<I> for Z0 where
I: Integer, Z0 + I = I
UInt<Ul, B0> + UInt<Ur, B1> = UInt<Ul + Ur, B1>
impl<Ul, Ur> Add<PInt<Ur>> for NInt<Ul> where
Ul: Unsigned + NonZero,
Ur: Unsigned + NonZero + Cmp<Ul> + PrivateIntegerAdd<<Ur as Cmp<Ul>>::Output, Ul>,
impl<Ul, Ur> Add<PInt<Ur>> for NInt<Ul> where
Ul: Unsigned + NonZero,
Ur: Unsigned + NonZero + Cmp<Ul> + PrivateIntegerAdd<<Ur as Cmp<Ul>>::Output, Ul>, N(Ul) + P(Ur): We resolve this with our PrivateAdd
UInt<Ul, B0> + UInt<Ur, B0> = UInt<Ul + Ur, B0>
impl<Ul, Ur> Add<NInt<Ur>> for PInt<Ul> where
Ul: Unsigned + NonZero + Cmp<Ur> + PrivateIntegerAdd<<Ul as Cmp<Ur>>::Output, Ur>,
Ur: Unsigned + NonZero,
impl<Ul, Ur> Add<NInt<Ur>> for PInt<Ul> where
Ul: Unsigned + NonZero + Cmp<Ur> + PrivateIntegerAdd<<Ul as Cmp<Ur>>::Output, Ur>,
Ur: Unsigned + NonZero, P(Ul) + N(Ur): We resolve this with our PrivateAdd
UInt<Ul, B1> + UInt<Ur, B1> = UInt<(Ul + Ur) + B1, B0>
N(Ul) + N(Ur) = N(Ul + Ur)
impl Add<B1> for UTerm
impl Add<B1> for UTermUTerm + B1 = UInt<UTerm, B1>
impl<U, B> Add<UTerm> for UInt<U, B> where
B: Bit,
U: Unsigned,
impl<U, B> Add<UTerm> for UInt<U, B> where
B: Bit,
U: Unsigned, UInt<U, B> + UTerm = UInt<U, B>
impl<U> Add<B1> for UInt<U, B0> where
U: Unsigned,
impl<U> Add<B1> for UInt<U, B0> where
U: Unsigned, UInt<U, B0> + B1 = UInt<U + B1>
impl Add<ATerm> for ATerm
impl Add<ATerm> for ATermUInt<U, B1> + B1 = UInt<U + B1, B0>
impl Add<B0> for UTerm
impl Add<B0> for UTermUTerm + B0 = UTerm
impl<U> Add<Z0> for PInt<U> where
U: Unsigned + NonZero,
impl<U> Add<Z0> for PInt<U> where
U: Unsigned + NonZero, PInt + Z0 = PInt
impl<U> Add<Z0> for NInt<U> where
U: Unsigned + NonZero,
impl<U> Add<Z0> for NInt<U> where
U: Unsigned + NonZero, NInt + Z0 = NInt
P(Ul) + P(Ur) = P(Ul + Ur)
impl<U> Add<U> for UTerm where
U: Unsigned,
impl<U> Add<U> for UTerm where
U: Unsigned, UTerm + U = U
impl<U, B> Add<B0> for UInt<U, B> where
B: Bit,
U: Unsigned,
impl<U, B> Add<B0> for UInt<U, B> where
B: Bit,
U: Unsigned, U + B0 = U
Implementors
Panics
This function may panic if the resulting point in time cannot be represented by the
underlying data structure. See SystemTime::checked_add for a version without panic.
type Output = SystemTime