[−][src]Trait core_extensions::ConstDefault
A const equivalent of the Default
trait.
Features
Enabling the "const_generics" feature allows arrays of all lengths to implement this trait, otherwise it's only implemented for arrays up to 32 elements long.
Example
Implementing ConstDefault
for a struct
// use core_extensions::const_default; // in newer versions of Rust. #[macro_use(const_default)] extern crate core_extensions; use core_extensions::ConstDefault; #[derive(Debug,PartialEq)] struct Point<T>{ x:T, y:T, } // `+ Copy` here is required for Rust 1.20 and 1.21, // and can be removed from Rust 1.22 onwards. impl<T> ConstDefault for Point<T> where T: ConstDefault + Copy { const DEFAULT: Self= Point{ x: T::DEFAULT, y: T::DEFAULT }; } assert_eq!( const_default!(Point<u8>), Point{x:0, y:0} ); assert_eq!( const_default!(Point<f32>), Point{x:0.0, y:0.0} ); assert_eq!( const_default!(Point<Option<()>>), Point{x:None, y:None} );
Associated Constants
Loading content...Implementations on Foreign Types
impl<T: ConstDefault, const N: usize> ConstDefault for [T; N]
[src]
This is supported on crate feature
const_params
only.When the "const_params" feature is disabled, the ConstDefault trait is implemented for arrays up to 32 elements long.
impl ConstDefault for ()
[src]
impl<A> ConstDefault for (A,) where
A: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
impl<A, B> ConstDefault for (A, B) where
A: ConstDefault + Sized,
B: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
impl<A, B, C> ConstDefault for (A, B, C) where
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
impl<A, B, C, D> ConstDefault for (A, B, C, D) where
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
impl<A, B, C, D, E> ConstDefault for (A, B, C, D, E) where
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
impl<A, B, C, D, E, F> ConstDefault for (A, B, C, D, E, F) where
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
impl<A, B, C, D, E, F, G> ConstDefault for (A, B, C, D, E, F, G) where
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
impl<A, B, C, D, E, F, G, H> ConstDefault for (A, B, C, D, E, F, G, H) where
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
impl<A, B, C, D, E, F, G, H, I> ConstDefault for (A, B, C, D, E, F, G, H, I) where
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
impl<A, B, C, D, E, F, G, H, I, J> ConstDefault for (A, B, C, D, E, F, G, H, I, J) where
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
J: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
J: ConstDefault + Sized,
impl<A, B, C, D, E, F, G, H, I, J, K> ConstDefault for (A, B, C, D, E, F, G, H, I, J, K) where
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
J: ConstDefault + Sized,
K: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
J: ConstDefault + Sized,
K: ConstDefault + Sized,
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 + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
J: ConstDefault + Sized,
K: ConstDefault + Sized,
L: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
J: ConstDefault + Sized,
K: ConstDefault + Sized,
L: ConstDefault + Sized,
impl<A, B, C, D, E, F, G, H, I, J, K, L, M> ConstDefault for (A, B, C, D, E, F, G, H, I, J, K, L, M) where
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
J: ConstDefault + Sized,
K: ConstDefault + Sized,
L: ConstDefault + Sized,
M: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
J: ConstDefault + Sized,
K: ConstDefault + Sized,
L: ConstDefault + Sized,
M: ConstDefault + Sized,
impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N> ConstDefault for (A, B, C, D, E, F, G, H, I, J, K, L, M, N) where
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
J: ConstDefault + Sized,
K: ConstDefault + Sized,
L: ConstDefault + Sized,
M: ConstDefault + Sized,
N: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
J: ConstDefault + Sized,
K: ConstDefault + Sized,
L: ConstDefault + Sized,
M: ConstDefault + Sized,
N: ConstDefault + Sized,
impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O> ConstDefault for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O) where
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
J: ConstDefault + Sized,
K: ConstDefault + Sized,
L: ConstDefault + Sized,
M: ConstDefault + Sized,
N: ConstDefault + Sized,
O: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
J: ConstDefault + Sized,
K: ConstDefault + Sized,
L: ConstDefault + Sized,
M: ConstDefault + Sized,
N: ConstDefault + Sized,
O: ConstDefault + Sized,
impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P> ConstDefault for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P) where
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
J: ConstDefault + Sized,
K: ConstDefault + Sized,
L: ConstDefault + Sized,
M: ConstDefault + Sized,
N: ConstDefault + Sized,
O: ConstDefault + Sized,
P: ConstDefault + Sized,
[src]
A: ConstDefault + Sized,
B: ConstDefault + Sized,
C: ConstDefault + Sized,
D: ConstDefault + Sized,
E: ConstDefault + Sized,
F: ConstDefault + Sized,
G: ConstDefault + Sized,
H: ConstDefault + Sized,
I: ConstDefault + Sized,
J: ConstDefault + Sized,
K: ConstDefault + Sized,
L: ConstDefault + Sized,
M: ConstDefault + Sized,
N: ConstDefault + Sized,
O: ConstDefault + Sized,
P: ConstDefault + Sized,