pub trait Displacement<T: ?Sized> {
type Output;
// Required method
fn displace(&self, other: &T) -> Self::Output;
}Expand description
The Displacement trait defines a way to displace a value of type T by another value of type T.
The displace method takes a reference to a T and returns a new value of the associated Output type,
which represents the displaced value.
Required Associated Types§
Required Methods§
Implementations on Foreign Types§
Source§impl Displacement<i32> for i32
Implements the Displacement trait for i32 types, providing a displace method that subtracts
the given i32 value from the current i32 value.
impl Displacement<i32> for i32
Implements the Displacement trait for i32 types, providing a displace method that subtracts
the given i32 value from the current i32 value.
Implementors§
Source§impl<T1, T2> Displacement<Point<T1, T2>> for Point<T1, T2>where
T1: Displacement<T1, Output = T1>,
T2: Displacement<T2, Output = T2>,
The above Rust code is implementing a Displacement trait for the Point struct. The
Displacement trait is generic over two types T1 and T2, and it requires that T1 and T2
implement the Displacement trait with an associated type Output.
impl<T1, T2> Displacement<Point<T1, T2>> for Point<T1, T2>where
T1: Displacement<T1, Output = T1>,
T2: Displacement<T2, Output = T2>,
The above Rust code is implementing a Displacement trait for the Point struct. The
Displacement trait is generic over two types T1 and T2, and it requires that T1 and T2
implement the Displacement trait with an associated type Output.