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", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl ConstDefault for PhantomPinned
impl ConstDefault for PhantomPinned
const DEFAULT: PhantomPinned = Self
Source§impl ConstDefault for AtomicBool
Available on crate feature enable-atomics only.
impl ConstDefault for AtomicBool
Available on crate feature
enable-atomics only.const DEFAULT: AtomicBool
Source§impl ConstDefault for AtomicI8
Available on crate feature enable-atomics only.
impl ConstDefault for AtomicI8
Available on crate feature
enable-atomics only.Source§impl ConstDefault for AtomicI16
Available on crate feature enable-atomics only.
impl ConstDefault for AtomicI16
Available on crate feature
enable-atomics only.Source§impl ConstDefault for AtomicI32
Available on crate feature enable-atomics only.
impl ConstDefault for AtomicI32
Available on crate feature
enable-atomics only.Source§impl ConstDefault for AtomicI64
Available on crate feature enable-atomics only.
impl ConstDefault for AtomicI64
Available on crate feature
enable-atomics only.Source§impl ConstDefault for AtomicIsize
Available on crate feature enable-atomics only.
impl ConstDefault for AtomicIsize
Available on crate feature
enable-atomics only.const DEFAULT: AtomicIsize
Source§impl ConstDefault for AtomicU8
Available on crate feature enable-atomics only.
impl ConstDefault for AtomicU8
Available on crate feature
enable-atomics only.Source§impl ConstDefault for AtomicU16
Available on crate feature enable-atomics only.
impl ConstDefault for AtomicU16
Available on crate feature
enable-atomics only.Source§impl ConstDefault for AtomicU32
Available on crate feature enable-atomics only.
impl ConstDefault for AtomicU32
Available on crate feature
enable-atomics only.Source§impl ConstDefault for AtomicU64
Available on crate feature enable-atomics only.
impl ConstDefault for AtomicU64
Available on crate feature
enable-atomics only.Source§impl ConstDefault for AtomicUsize
Available on crate feature enable-atomics only.
impl ConstDefault for AtomicUsize
Available on crate feature
enable-atomics only.const DEFAULT: AtomicUsize
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> 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 PhantomData<T>where
T: ?Sized,
impl<T> ConstDefault for PhantomData<T>where
T: ?Sized,
const DEFAULT: PhantomData<T> = Self
Source§impl<T> ConstDefault for ManuallyDrop<T>where
T: ConstDefault,
impl<T> ConstDefault for ManuallyDrop<T>where
T: ConstDefault,
const DEFAULT: ManuallyDrop<T>
Source§impl<T> ConstDefault for Wrapping<T>where
T: ConstDefault,
impl<T> ConstDefault for Wrapping<T>where
T: ConstDefault,
Source§impl<T> ConstDefault for AtomicPtr<T>
Available on crate feature enable-atomics only.
impl<T> ConstDefault for AtomicPtr<T>
Available on crate feature
enable-atomics only.