const_default

Trait 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§

Source

const DEFAULT: Self

The constant default value.

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§

Source§

impl ConstDefault for &&str

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &bool

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &char

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &f32

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &f64

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &i8

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &i16

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &i32

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &i64

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &i128

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &isize

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &str

Source§

const DEFAULT: Self = ""

Source§

impl ConstDefault for &u8

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &u16

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &u32

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &u64

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &u128

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &()

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for &usize

Source§

const DEFAULT: Self = _

Source§

impl ConstDefault for bool

Source§

const DEFAULT: Self = false

Source§

impl ConstDefault for char

Source§

const DEFAULT: Self = '\0'

Source§

impl ConstDefault for f32

Source§

const DEFAULT: Self = 0f32

Source§

impl ConstDefault for f64

Source§

const DEFAULT: Self = 0f64

Source§

impl ConstDefault for i8

Source§

const DEFAULT: Self = 0i8

Source§

impl ConstDefault for i16

Source§

const DEFAULT: Self = 0i16

Source§

impl ConstDefault for i32

Source§

const DEFAULT: Self = 0i32

Source§

impl ConstDefault for i64

Source§

const DEFAULT: Self = 0i64

Source§

impl ConstDefault for i128

Source§

const DEFAULT: Self = 0i128

Source§

impl ConstDefault for isize

Source§

const DEFAULT: Self = 0isize

Source§

impl ConstDefault for u8

Source§

const DEFAULT: Self = 0u8

Source§

impl ConstDefault for u16

Source§

const DEFAULT: Self = 0u16

Source§

impl ConstDefault for u32

Source§

const DEFAULT: Self = 0u32

Source§

impl ConstDefault for u64

Source§

const DEFAULT: Self = 0u64

Source§

impl ConstDefault for u128

Source§

const DEFAULT: Self = 0u128

Source§

impl ConstDefault for ()

Source§

const DEFAULT: Self = ()

Source§

impl ConstDefault for usize

Source§

const DEFAULT: Self = 0usize

Source§

impl ConstDefault for PhantomPinned

Source§

const DEFAULT: Self = Self

Source§

impl ConstDefault for Duration

Source§

const DEFAULT: Self = _

Source§

impl<'a, T: 'a> ConstDefault for &'a [T]

Source§

const DEFAULT: Self = _

Source§

impl<A: ConstDefault, B: ConstDefault, C: ConstDefault, D: ConstDefault, E: ConstDefault, F: ConstDefault, G: ConstDefault, H: ConstDefault, I: ConstDefault, J: ConstDefault, K: ConstDefault, L: ConstDefault> ConstDefault for (A, B, C, D, E, F, G, H, I, J, K, L)

Source§

const DEFAULT: Self = _

Source§

impl<B: ConstDefault, C: ConstDefault, D: ConstDefault, E: ConstDefault, F: ConstDefault, G: ConstDefault, H: ConstDefault, I: ConstDefault, J: ConstDefault, K: ConstDefault, L: ConstDefault> ConstDefault for (B, C, D, E, F, G, H, I, J, K, L)

Source§

const DEFAULT: Self = _

Source§

impl<C: ConstDefault, D: ConstDefault, E: ConstDefault, F: ConstDefault, G: ConstDefault, H: ConstDefault, I: ConstDefault, J: ConstDefault, K: ConstDefault, L: ConstDefault> ConstDefault for (C, D, E, F, G, H, I, J, K, L)

Source§

const DEFAULT: Self = _

Source§

impl<D: ConstDefault, E: ConstDefault, F: ConstDefault, G: ConstDefault, H: ConstDefault, I: ConstDefault, J: ConstDefault, K: ConstDefault, L: ConstDefault> ConstDefault for (D, E, F, G, H, I, J, K, L)

Source§

const DEFAULT: Self = _

Source§

impl<E: ConstDefault, F: ConstDefault, G: ConstDefault, H: ConstDefault, I: ConstDefault, J: ConstDefault, K: ConstDefault, L: ConstDefault> ConstDefault for (E, F, G, H, I, J, K, L)

Source§

const DEFAULT: Self = _

Source§

impl<F: ConstDefault, G: ConstDefault, H: ConstDefault, I: ConstDefault, J: ConstDefault, K: ConstDefault, L: ConstDefault> ConstDefault for (F, G, H, I, J, K, L)

Source§

const DEFAULT: Self = _

Source§

impl<G: ConstDefault, H: ConstDefault, I: ConstDefault, J: ConstDefault, K: ConstDefault, L: ConstDefault> ConstDefault for (G, H, I, J, K, L)

Source§

const DEFAULT: Self = _

Source§

impl<H: ConstDefault, I: ConstDefault, J: ConstDefault, K: ConstDefault, L: ConstDefault> ConstDefault for (H, I, J, K, L)

Source§

const DEFAULT: Self = _

Source§

impl<I: ConstDefault, J: ConstDefault, K: ConstDefault, L: ConstDefault> ConstDefault for (I, J, K, L)

Source§

const DEFAULT: Self = _

Source§

impl<J: ConstDefault, K: ConstDefault, L: ConstDefault> ConstDefault for (J, K, L)

Source§

const DEFAULT: Self = _

Source§

impl<K: ConstDefault, L: ConstDefault> ConstDefault for (K, L)

Source§

const DEFAULT: Self = _

Source§

impl<L: ConstDefault> ConstDefault for (L,)

Source§

const DEFAULT: Self = _

Source§

impl<T> ConstDefault for Option<T>

Source§

const DEFAULT: Self = None

Source§

impl<T> ConstDefault for *const T

Source§

const DEFAULT: Self = _

Source§

impl<T> ConstDefault for *mut T

Source§

const DEFAULT: Self = _

Source§

impl<T> ConstDefault for Empty<T>

Source§

const DEFAULT: Self = _

Source§

impl<T: ConstDefault> ConstDefault for Cell<T>

Source§

const DEFAULT: Self = _

Source§

impl<T: ConstDefault> ConstDefault for RefCell<T>

Source§

const DEFAULT: Self = _

Source§

impl<T: ConstDefault> ConstDefault for UnsafeCell<T>

Source§

const DEFAULT: Self = _

Source§

impl<T: ConstDefault> ConstDefault for ManuallyDrop<T>

Source§

const DEFAULT: Self = _

Source§

impl<T: ConstDefault> ConstDefault for Wrapping<T>

Source§

const DEFAULT: Self = _

Source§

impl<T: ConstDefault> ConstDefault for MaybeUninit<T>

Source§

const DEFAULT: Self = _

Source§

impl<T: ConstDefault, const N: usize> ConstDefault for [T; N]

Source§

const DEFAULT: Self = _

Source§

impl<T: ?Sized> ConstDefault for PhantomData<T>

Source§

const DEFAULT: Self = Self

Implementors§