pub trait Dummy {
// Required method
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§
Sourceunsafe fn dummy() -> Self
unsafe fn dummy() -> Self
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Implementors§
impl<O: Dummy> Dummy for ClumpedOffsets<O>
A dummy set of offsets will not allocate, but the resulting type does not correspond to valid offsets.