pub struct Tup2<A, B>(pub FieldMarker<A>, pub FieldMarker<B>);
Expand description
Tuple of variable-length types.
Examples
use varlen::prelude::*;
use varlen::Layout;
let mut t: VBox<Tup2<Str, Str>> = VBox::new(tup2::Init(
Str::copy("hello"),
Str::copy("world"),
));
assert_eq!(&t.refs().0[..], "hello");
assert_eq!(&t.refs().1[..], "world");
t.as_mut().muts().0.mut_slice().make_ascii_uppercase();
assert_eq!(&t.refs().0[..], "HELLO");
assert_eq!(&t.refs().1[..], "world");
assert_eq!(t.calculate_layout().size(),
core::mem::size_of::<usize>() * 2 + 8 /* hello */ + 5 /* world */);
Tuple Fields
0: FieldMarker<A>
1: FieldMarker<B>
Implementations
sourceimpl<A: VarLen, B: VarLen> Tup2<A, B>
impl<A: VarLen, B: VarLen> Tup2<A, B>
sourcepub fn refs(&self) -> Refs<'_, A, B>
pub fn refs(&self) -> Refs<'_, A, B>
Immutable access to fields of a tuple.
Examples
use varlen::prelude::*;
use varlen::Layout;
let mut t: VBox<Tup2<Str, Str>> = VBox::new(tup2::Init(
Str::copy("hello"),
Str::copy("world"),
));
assert_eq!(&t.refs().0[..], "hello");
assert_eq!(&t.refs().1[..], "world");
t.as_mut().muts().0.mut_slice().make_ascii_uppercase();
assert_eq!(&t.refs().0[..], "HELLO");
assert_eq!(&t.refs().1[..], "world");
assert_eq!(t.calculate_layout().size(),
core::mem::size_of::<usize>() * 2 + 8 /* hello */ + 5 /* world */);
sourcepub fn muts(self: Pin<&mut Self>) -> Muts<'_, A, B>
pub fn muts(self: Pin<&mut Self>) -> Muts<'_, A, B>
Mutable access to fields of a tuple.
Examples
use varlen::prelude::*;
use varlen::Layout;
let mut t: VBox<Tup2<Str, Str>> = VBox::new(tup2::Init(
Str::copy("hello"),
Str::copy("world"),
));
assert_eq!(&t.refs().0[..], "hello");
assert_eq!(&t.refs().1[..], "world");
t.as_mut().muts().0.mut_slice().make_ascii_uppercase();
assert_eq!(&t.refs().0[..], "HELLO");
assert_eq!(&t.refs().1[..], "world");
assert_eq!(t.calculate_layout().size(),
core::mem::size_of::<usize>() * 2 + 8 /* hello */ + 5 /* world */);
Trait Implementations
sourceimpl<'a, A: VClone<'a>, B: VClone<'a>> Initializer<Tup2<A, B>> for Cloner<'a, A, B>
impl<'a, A: VClone<'a>, B: VClone<'a>> Initializer<Tup2<A, B>> for Cloner<'a, A, B>
sourceimpl<A: VarLen, AInit: Initializer<A>, B: VarLen, BInit: Initializer<B>> Initializer<Tup2<A, B>> for Init<AInit, BInit>
impl<A: VarLen, AInit: Initializer<A>, B: VarLen, BInit: Initializer<B>> Initializer<Tup2<A, B>> for Init<AInit, BInit>
sourcefn calculate_layout_cautious(&self) -> Option<Layout<A, B>>
fn calculate_layout_cautious(&self) -> Option<Layout<A, B>>
Calculates the layout of the object, returning None
if any of the calculated sizes
or offsets would overflow usize
. Read more
sourceimpl<A: VarLen, B: VarLen> VarLen for Tup2<A, B>
impl<A: VarLen, B: VarLen> VarLen for Tup2<A, B>
type Layout = Layout<A, B>
type Layout = Layout<A, B>
This type’s internal dynamic calculations of where its tail fields are. Read more
sourceconst NEEDS_VDROP: bool
const NEEDS_VDROP: bool
sourcefn calculate_layout(&self) -> Layout<A, B>
fn calculate_layout(&self) -> Layout<A, B>
Calculates the layout of the internal fields of this object. Read more
Auto Trait Implementations
impl<A, B> RefUnwindSafe for Tup2<A, B> where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Send for Tup2<A, B> where
A: Send,
B: Send,
impl<A, B> Sync for Tup2<A, B> where
A: Sync,
B: Sync,
impl<A, B> !Unpin for Tup2<A, B>
impl<A, B> UnwindSafe for Tup2<A, B> where
A: UnwindSafe,
B: 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