#[repr(transparent)]pub struct Distance<T, const D: usize> {
pub dim: [T; D],
}Expand description
๐
A separation between two locations in D-dimensional space.
๐ geom/metric
Represents a displacement vector without an absolute origin. It describes the magnitude of separation between positions.
- Unlike
Position,Distanceis relative, and represents how far apart two positions are. - Unlike
Orientation,Distancehas magnitude but no defined direction.
Fieldsยง
ยงdim: [T; D]The component-wise separation in D-dimensional space.
Implementationsยง
Sourceยงimpl<T, const D: usize> Distance<T, D>
impl<T, const D: usize> Distance<T, D>
Sourcepub const fn new(dimensions: [T; D]) -> Self
pub const fn new(dimensions: [T; D]) -> Self
Constructs a new Distance from the given dimensions.
Sourcepub const fn as_slice(&self) -> &[T] โ
pub const fn as_slice(&self) -> &[T] โ
Returns a shared reference to the distance as a slice.
Sourcepub const fn as_slice_mut(&mut self) -> &mut [T] โ
pub const fn as_slice_mut(&mut self) -> &mut [T] โ
Returns an exclusive reference to the distance as a slice.
Sourcepub fn is_uniform_nd(&self) -> boolwhere
T: PartialEq,
pub fn is_uniform_nd(&self) -> boolwhere
T: PartialEq,
Returns true if all dimensions of the extent are equal.
Returns true if all dimensions of the distance are equal.
Sourcepub fn map<U>(self, f: impl FnMut(T) -> U) -> Distance<U, D>
pub fn map<U>(self, f: impl FnMut(T) -> U) -> Distance<U, D>
Returns a new Distance by applying f to each dimension.
This is a runtime, dimension-preserving transformation.
It is useful for reshaping the inner scalar type without introducing
blanket From/TryFrom impl conflicts on the wrapper itself.
Sourcepub fn try_map<U, E>(
self,
f: impl FnMut(T) -> Result<U, E>,
) -> Result<Distance<U, D>, E> โ
pub fn try_map<U, E>( self, f: impl FnMut(T) -> Result<U, E>, ) -> Result<Distance<U, D>, E> โ
Returns a new Distance by fallibly applying f to each dimension.
Stops at the first conversion error and returns it.
This is the fallible counterpart to map, and is the
recommended runtime path for per-dimension checked conversion.
Trait Implementationsยง
impl<T: Copy, const D: usize> Copy for Distance<T, D>
impl<T: Eq, const D: usize> Eq for Distance<T, D>
Sourceยงimpl<T> From<(T, T, T, T)> for Distance<T, 4>
impl<T> From<(T, T, T, T)> for Distance<T, 4>
Sourceยงfn from(dim: (T, T, T, T)) -> Self
fn from(dim: (T, T, T, T)) -> Self
Sourceยงimpl<T: Ord, const D: usize> Ord for Distance<T, D>
impl<T: Ord, const D: usize> Ord for Distance<T, D>
1.21.0 (const: unstable) ยท Sourceยงfn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Sourceยงimpl<T: PartialOrd, const D: usize> PartialOrd for Distance<T, D>
impl<T: PartialOrd, const D: usize> PartialOrd for Distance<T, D>
Auto Trait Implementationsยง
impl<T, const D: usize> Freeze for Distance<T, D>where
T: Freeze,
impl<T, const D: usize> RefUnwindSafe for Distance<T, D>where
T: RefUnwindSafe,
impl<T, const D: usize> Send for Distance<T, D>where
T: Send,
impl<T, const D: usize> Sync for Distance<T, D>where
T: Sync,
impl<T, const D: usize> Unpin for Distance<T, D>where
T: Unpin,
impl<T, const D: usize> UnsafeUnpin for Distance<T, D>where
T: UnsafeUnpin,
impl<T, const D: usize> UnwindSafe for Distance<T, D>where
T: UnwindSafe,
Blanket Implementationsยง
Sourceยงimpl<T> AnyExt for T
impl<T> AnyExt for T
Sourceยงfn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId of Self using a custom hasher.Sourceยงfn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Sourceยงfn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
alloc only.Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> ByteSized for T
impl<T> ByteSized for T
Sourceยงconst BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Sourceยงfn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Sourceยงfn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงimpl<T> MemExt for Twhere
T: ?Sized,
impl<T> MemExt for Twhere
T: ?Sized,
Sourceยงconst NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Sourceยงfn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Sourceยงfn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Sourceยงfn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Sourceยงfn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Sourceยงfn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true if dropping values of this type matters. Read moreSourceยงfn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self without running its destructor. Read moreSourceยงfn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Sourceยงunsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงunsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงfn mem_as_bytes(&self) -> &[u8] โ
fn mem_as_bytes(&self) -> &[u8] โ
unsafe_slice only.