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

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 */);

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

Executes the destructor for this type. Read more

Calculates the layout of the object, returning None if any of the calculated sizes or offsets would overflow usize. Read more

Populates the destination pointer. Read more

Calculates the layout of the object, returning None if any of the calculated sizes or offsets would overflow usize. Read more

Populates the destination pointer. Read more

An initializer that can produce a clone of an object of type Self. Read more

Returns an initializer that will clone self when run. Read more

Returns an initializer that does a bulk byte copy of self. Read more

This type’s internal dynamic calculations of where its tail fields are. Read more

Alignment of this type, including its fixed-length header. Read more

If false, vdrop() is a noop, and may be skipped without changing behavior. Read more

Calculates the layout of the internal fields of this object. Read more

Drops self. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.