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

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

Calculates the layout of the internal fields of this object. 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

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.