pub struct Const<const N: usize>;
Expand description
A tag using a const generic length parameter.
The only safe way to construct an ExactSize
is by copying the associated constant which
expresses the length indicated in the trait impl. This implies that the value is unique.
Usage
use index_ext::tag::{Const, Slice};
let size = Const::<8>::EXACT_SIZE;
let data = [0, 1, 2, 3, 4, 5, 6, 7];
let slice = Slice::new(&data[..], size).unwrap();
let prefix = size
.into_len()
.truncate(4)
.range_to_self();
let prefix = &slice[prefix];
assert_eq!(prefix, [0, 1, 2, 3]);
Implementations§
source§impl<const N: usize> Const<N>
impl<const N: usize> Const<N>
sourcepub const EXACT_SIZE: ExactSize<Self> = _
pub const EXACT_SIZE: ExactSize<Self> = _
A constructed instance of ExactSize<Self>
.
The instance can be freely copied. Making this an associated constant ensures that the
length associated with the type is the constant parameter N
. There are no other safe
constructors for this tag’s ExactSize
type.
Trait Implementations§
impl<const N: usize> Copy for Const<N>
impl<const N: usize> Tag for Const<N>
Auto Trait Implementations§
impl<const N: usize> RefUnwindSafe for Const<N>
impl<const N: usize> Send for Const<N>
impl<const N: usize> Sync for Const<N>
impl<const N: usize> Unpin for Const<N>
impl<const N: usize> UnwindSafe for Const<N>
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