Trait flatk::Dummy[][src]

pub trait Dummy {
    unsafe fn dummy() -> Self;
}
Expand description

A helper trait for constructing placeholder sets for use in std::mem::replace.

These don’t necessarily have to correspond to bona-fide sets and can potentially produce invalid sets. For this reason this function can be unsafe since it can generate collections that don’t uphold their invariants for the sake of avoiding allocations.

Required methods

Constructs a potentially invalid instance of a type.

This function is intended to be used in conjunction with std::mem::replace to avoid allocations for types whose Default implementations can cause allocations or other potentially expensive computations. As such dummy types may be invalid and should not be used other than as placeholders to avoid undefined behaviour.

Safety

Instances created with this function can cause undefinied behaviour if used other than as placeholders for real values for functions like std::mem::replace.

Implementations on Foreign Types

Implementors

A dummy set of offsets will not allocate, but the resulting type does not correspond to valid offsets.