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.
§Examples
use physdes::generic::Displacement;
let a: i32 = 10;
let b: i32 = 5;
let displacement = a.displace(&b);
assert_eq!(displacement, 5);
let a: i32 = 5;
let b: i32 = 10;
let displacement = a.displace(&b);
assert_eq!(displacement, -5);Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
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.
§Examples
use physdes::generic::Displacement;
let a: i32 = 10;
let b: i32 = 5;
let displacement = a.displace(&b);
assert_eq!(displacement, 5);
let a: i32 = 5;
let b: i32 = 10;
let displacement = a.displace(&b);
assert_eq!(displacement, -5);