Trait const_default::ConstDefault
source · pub trait ConstDefault: Sized {
const DEFAULT: Self;
}
Expand description
Implements a compilation time default value for the implemented type.
§Note
Unlike the Default
trait implementation the DEFAULT
of implementations
of this trait can be used in constant evaluation contexts.
§Example
const VEC: Vec<u8> = <Vec<u8> as ConstDefault>::DEFAULT;
The above code works while the below code does not:
ⓘ
const VEC: Vec<u8> = <Vec<u8> as Default>::default();
Required Associated Constants§
Object Safety§
This trait is not object safe.