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§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<A, B, C, D, E, F, G, H, I, J, K, L> ConstDefault for (A, B, C, D, E, F, G, H, I, J, K, L)where
A: ConstDefault,
B: ConstDefault,
C: ConstDefault,
D: ConstDefault,
E: ConstDefault,
F: ConstDefault,
G: ConstDefault,
H: ConstDefault,
I: ConstDefault,
J: ConstDefault,
K: ConstDefault,
L: ConstDefault,
impl<A, B, C, D, E, F, G, H, I, J, K, L> ConstDefault for (A, B, C, D, E, F, G, H, I, J, K, L)where
A: ConstDefault,
B: ConstDefault,
C: ConstDefault,
D: ConstDefault,
E: ConstDefault,
F: ConstDefault,
G: ConstDefault,
H: ConstDefault,
I: ConstDefault,
J: ConstDefault,
K: ConstDefault,
L: ConstDefault,
Source§impl<B, C, D, E, F, G, H, I, J, K, L> ConstDefault for (B, C, D, E, F, G, H, I, J, K, L)where
B: ConstDefault,
C: ConstDefault,
D: ConstDefault,
E: ConstDefault,
F: ConstDefault,
G: ConstDefault,
H: ConstDefault,
I: ConstDefault,
J: ConstDefault,
K: ConstDefault,
L: ConstDefault,
impl<B, C, D, E, F, G, H, I, J, K, L> ConstDefault for (B, C, D, E, F, G, H, I, J, K, L)where
B: ConstDefault,
C: ConstDefault,
D: ConstDefault,
E: ConstDefault,
F: ConstDefault,
G: ConstDefault,
H: ConstDefault,
I: ConstDefault,
J: ConstDefault,
K: ConstDefault,
L: ConstDefault,
Source§impl<C, D, E, F, G, H, I, J, K, L> ConstDefault for (C, D, E, F, G, H, I, J, K, L)where
C: ConstDefault,
D: ConstDefault,
E: ConstDefault,
F: ConstDefault,
G: ConstDefault,
H: ConstDefault,
I: ConstDefault,
J: ConstDefault,
K: ConstDefault,
L: ConstDefault,
impl<C, D, E, F, G, H, I, J, K, L> ConstDefault for (C, D, E, F, G, H, I, J, K, L)where
C: ConstDefault,
D: ConstDefault,
E: ConstDefault,
F: ConstDefault,
G: ConstDefault,
H: ConstDefault,
I: ConstDefault,
J: ConstDefault,
K: ConstDefault,
L: ConstDefault,
Source§impl<D, E, F, G, H, I, J, K, L> ConstDefault for (D, E, F, G, H, I, J, K, L)where
D: ConstDefault,
E: ConstDefault,
F: ConstDefault,
G: ConstDefault,
H: ConstDefault,
I: ConstDefault,
J: ConstDefault,
K: ConstDefault,
L: ConstDefault,
impl<D, E, F, G, H, I, J, K, L> ConstDefault for (D, E, F, G, H, I, J, K, L)where
D: ConstDefault,
E: ConstDefault,
F: ConstDefault,
G: ConstDefault,
H: ConstDefault,
I: ConstDefault,
J: ConstDefault,
K: ConstDefault,
L: ConstDefault,
Source§impl<E, F, G, H, I, J, K, L> ConstDefault for (E, F, G, H, I, J, K, L)where
E: ConstDefault,
F: ConstDefault,
G: ConstDefault,
H: ConstDefault,
I: ConstDefault,
J: ConstDefault,
K: ConstDefault,
L: ConstDefault,
impl<E, F, G, H, I, J, K, L> ConstDefault for (E, F, G, H, I, J, K, L)where
E: ConstDefault,
F: ConstDefault,
G: ConstDefault,
H: ConstDefault,
I: ConstDefault,
J: ConstDefault,
K: ConstDefault,
L: ConstDefault,
Source§impl<F, G, H, I, J, K, L> ConstDefault for (F, G, H, I, J, K, L)where
F: ConstDefault,
G: ConstDefault,
H: ConstDefault,
I: ConstDefault,
J: ConstDefault,
K: ConstDefault,
L: ConstDefault,
impl<F, G, H, I, J, K, L> ConstDefault for (F, G, H, I, J, K, L)where
F: ConstDefault,
G: ConstDefault,
H: ConstDefault,
I: ConstDefault,
J: ConstDefault,
K: ConstDefault,
L: ConstDefault,
Source§impl<G, H, I, J, K, L> ConstDefault for (G, H, I, J, K, L)where
G: ConstDefault,
H: ConstDefault,
I: ConstDefault,
J: ConstDefault,
K: ConstDefault,
L: ConstDefault,
impl<G, H, I, J, K, L> ConstDefault for (G, H, I, J, K, L)where
G: ConstDefault,
H: ConstDefault,
I: ConstDefault,
J: ConstDefault,
K: ConstDefault,
L: ConstDefault,
const DEFAULT: (G, H, I, J, K, L)
Source§impl<H, I, J, K, L> ConstDefault for (H, I, J, K, L)
impl<H, I, J, K, L> ConstDefault for (H, I, J, K, L)
const DEFAULT: (H, I, J, K, L)
Source§impl<I, J, K, L> ConstDefault for (I, J, K, L)
impl<I, J, K, L> ConstDefault for (I, J, K, L)
const DEFAULT: (I, J, K, L)
Source§impl<J, K, L> ConstDefault for (J, K, L)
impl<J, K, L> ConstDefault for (J, K, L)
Source§impl<K, L> ConstDefault for (K, L)where
K: ConstDefault,
L: ConstDefault,
impl<K, L> ConstDefault for (K, L)where
K: ConstDefault,
L: ConstDefault,
Source§impl<L> ConstDefault for (L,)where
L: ConstDefault,
impl<L> ConstDefault for (L,)where
L: ConstDefault,
Source§impl<T, const N: usize> ConstDefault for [T; N]where
T: ConstDefault,
impl<T, const N: usize> ConstDefault for [T; N]where
T: ConstDefault,
Implementors§
Source§impl ConstDefault for PhantomPinned
impl ConstDefault for PhantomPinned
const DEFAULT: PhantomPinned = Self
Source§impl ConstDefault for Atomic<bool>
Available on crate feature enable-atomics only.
impl ConstDefault for Atomic<bool>
Available on crate feature
enable-atomics only.Source§impl ConstDefault for Atomic<i8>
Available on crate feature enable-atomics only.
impl ConstDefault for Atomic<i8>
Available on crate feature
enable-atomics only.Source§impl ConstDefault for Atomic<i16>
Available on crate feature enable-atomics only.
impl ConstDefault for Atomic<i16>
Available on crate feature
enable-atomics only.Source§impl ConstDefault for Atomic<i32>
Available on crate feature enable-atomics only.
impl ConstDefault for Atomic<i32>
Available on crate feature
enable-atomics only.Source§impl ConstDefault for Atomic<i64>
Available on crate feature enable-atomics only.
impl ConstDefault for Atomic<i64>
Available on crate feature
enable-atomics only.Source§impl ConstDefault for Atomic<isize>
Available on crate feature enable-atomics only.
impl ConstDefault for Atomic<isize>
Available on crate feature
enable-atomics only.Source§impl ConstDefault for Atomic<u8>
Available on crate feature enable-atomics only.
impl ConstDefault for Atomic<u8>
Available on crate feature
enable-atomics only.Source§impl ConstDefault for Atomic<u16>
Available on crate feature enable-atomics only.
impl ConstDefault for Atomic<u16>
Available on crate feature
enable-atomics only.Source§impl ConstDefault for Atomic<u32>
Available on crate feature enable-atomics only.
impl ConstDefault for Atomic<u32>
Available on crate feature
enable-atomics only.Source§impl ConstDefault for Atomic<u64>
Available on crate feature enable-atomics only.
impl ConstDefault for Atomic<u64>
Available on crate feature
enable-atomics only.Source§impl ConstDefault for Atomic<usize>
Available on crate feature enable-atomics only.
impl ConstDefault for Atomic<usize>
Available on crate feature
enable-atomics only.Source§impl ConstDefault for FaceIdwhere
u8: ConstDefault,
impl ConstDefault for FaceIdwhere
u8: ConstDefault,
Source§impl<T> ConstDefault for Cell<T>where
T: ConstDefault,
impl<T> ConstDefault for Cell<T>where
T: ConstDefault,
Source§impl<T> ConstDefault for RefCell<T>where
T: ConstDefault,
impl<T> ConstDefault for RefCell<T>where
T: ConstDefault,
Source§impl<T> ConstDefault for UnsafeCell<T>where
T: ConstDefault,
impl<T> ConstDefault for UnsafeCell<T>where
T: ConstDefault,
const DEFAULT: UnsafeCell<T>
Source§impl<T> ConstDefault for Atomic<*mut T>
Available on crate feature enable-atomics only.
impl<T> ConstDefault for Atomic<*mut T>
Available on crate feature
enable-atomics only.