pub struct Canonical<T>(/* private fields */);Expand description
Type-safe envelope for immutable, canonical data.
Implementations§
Source§impl<T> Canonical<T>where
T: IsCanonical + Debug,
impl<T> Canonical<T>where
T: IsCanonical + Debug,
Sourcepub fn tie(canonical: T) -> Self
pub fn tie(canonical: T) -> Self
Enclose the argument into an immutable Canonical envelope.
The caller is responsible to ensure that the argument is considered
as canonical, e.g. by invoking Canonicalize::canonicalize()
beforehand if needed. A debug assertion verifies at runtime that
the given argument is canonical.
Sourcepub const fn tie_unchecked(canonical: T) -> Self
pub const fn tie_unchecked(canonical: T) -> Self
Enclose the argument into an immutable Canonical envelope.
const fn version of Canonical::tie() without a debug assertion.
Use deliberately!
Source§impl<T> Canonical<T>where
T: IsCanonical,
impl<T> Canonical<T>where
T: IsCanonical,
pub fn as_canonical_ref(&self) -> Canonical<&T>
Source§impl<T> Canonical<Vec<T>>where
T: IsCanonical,
impl<T> Canonical<Vec<T>>where
T: IsCanonical,
pub fn as_canonical_slice(&self) -> Canonical<&[T]>
Trait Implementations§
Source§impl<T> IsCanonical for Canonical<T>where
T: IsCanonical,
impl<T> IsCanonical for Canonical<T>where
T: IsCanonical,
Source§fn is_canonical(&self) -> bool
fn is_canonical(&self) -> bool
Check if the representation of
self is canonical.Source§impl<T: Ord> Ord for Canonical<T>
impl<T: Ord> Ord for Canonical<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for Canonical<T>
impl<T: PartialOrd> PartialOrd for Canonical<T>
impl<T: Copy> Copy for Canonical<T>
impl<T: Eq> Eq for Canonical<T>
impl<T> StructuralPartialEq for Canonical<T>
Auto Trait Implementations§
impl<T> Freeze for Canonical<T>where
T: Freeze,
impl<T> RefUnwindSafe for Canonical<T>where
T: RefUnwindSafe,
impl<T> Send for Canonical<T>where
T: Send,
impl<T> Sync for Canonical<T>where
T: Sync,
impl<T> Unpin for Canonical<T>where
T: Unpin,
impl<T> UnwindSafe for Canonical<T>where
T: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more