pub struct FixedLen<T>(pub T);
Expand description
Presents a fixed-length type T
as a variable-length type.
Useful for creating tuples consisting of some variable-length types and some fixed-length types.
Examples
Put a fixed-length type in a variable-sized box:
use varlen::prelude::*;
let b: VBox<FixedLen<u16>> = VBox::new(FixedLen(4));
assert_eq!(b.0, 4);
Create a tuple of variable-length types and a fixed-length type:
use varlen::prelude::*;
let b: VBox<Tup2<FixedLen<u16>, Str>> = VBox::new(tup2::Init(
FixedLen(4), Str::copy("hello")));
assert_eq!(b.refs().0.0, 4);
assert_eq!(&b.refs().1[..], "hello");
Tuple Fields
0: T
Trait Implementations
sourceimpl<T> Initializer<FixedLen<T>> for FixedLen<T>
impl<T> Initializer<FixedLen<T>> for FixedLen<T>
sourcefn calculate_layout_cautious(&self) -> Option<FixedLenLayout<T>>
fn calculate_layout_cautious(&self) -> Option<FixedLenLayout<T>>
Calculates the layout of the object, returning None
if any of the calculated sizes
or offsets would overflow usize
. Read more
sourceunsafe fn initialize(
self,
dst: NonNull<FixedLen<T>>,
_layout: FixedLenLayout<T>
)
unsafe fn initialize(
self,
dst: NonNull<FixedLen<T>>,
_layout: FixedLenLayout<T>
)
Populates the destination pointer. Read more
sourceimpl<'a, T: Clone> Initializer<FixedLen<T>> for FixedLenCloner<'a, T>
impl<'a, T: Clone> Initializer<FixedLen<T>> for FixedLenCloner<'a, T>
sourcefn calculate_layout_cautious(&self) -> Option<FixedLenLayout<T>>
fn calculate_layout_cautious(&self) -> Option<FixedLenLayout<T>>
Calculates the layout of the object, returning None
if any of the calculated sizes
or offsets would overflow usize
. Read more
sourceunsafe fn initialize(
self,
dst: NonNull<FixedLen<T>>,
_layout: FixedLenLayout<T>
)
unsafe fn initialize(
self,
dst: NonNull<FixedLen<T>>,
_layout: FixedLenLayout<T>
)
Populates the destination pointer. Read more
sourceimpl<T> VarLen for FixedLen<T>
impl<T> VarLen for FixedLen<T>
type Layout = FixedLenLayout<T>
type Layout = FixedLenLayout<T>
This type’s internal dynamic calculations of where its tail fields are. Read more
sourcefn calculate_layout(&self) -> Self::Layout
fn calculate_layout(&self) -> Self::Layout
Calculates the layout of the internal fields of this object. Read more
sourceconst NEEDS_VDROP: bool
const NEEDS_VDROP: bool
Auto Trait Implementations
impl<T> RefUnwindSafe for FixedLen<T> where
T: RefUnwindSafe,
impl<T> Send for FixedLen<T> where
T: Send,
impl<T> Sync for FixedLen<T> where
T: Sync,
impl<T> Unpin for FixedLen<T> where
T: Unpin,
impl<T> UnwindSafe for FixedLen<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more