Trait wasmtime_wiggle::bitflags::_core::prelude::rust_2018::Default 1.0.0[−][src]
pub trait Default { fn default() -> Self; }
Expand description
A trait for giving a type a useful default value.
Sometimes, you want to fall back to some kind of default value, and
don’t particularly care what it is. This comes up often with struct
s
that define a set of options:
struct SomeOptions { foo: i32, bar: f32, }
How can we define some default values? You can use Default
:
#[derive(Default)] struct SomeOptions { foo: i32, bar: f32, } fn main() { let options: SomeOptions = Default::default(); }
Now, you get all of the default values. Rust implements Default
for various primitives types.
If you want to override a particular option, but still retain the other defaults:
fn main() { let options = SomeOptions { foo: 42, ..Default::default() }; }
Derivable
This trait can be used with #[derive]
if all of the type’s fields implement
Default
. When derive
d, it will use the default value for each field’s type.
How can I implement Default
?
Provide an implementation for the default()
method that returns the value of
your type that should be the default:
enum Kind { A, B, C, } impl Default for Kind { fn default() -> Self { Kind::A } }
Examples
#[derive(Default)] struct SomeOptions { foo: i32, bar: f32, }
Required methods
fn default() -> Self
[src]
fn default() -> Self
[src]Returns the “default value” for a type.
Default values are often some kind of initial value, identity value, or anything else that may make sense as a default.
Examples
Using built-in default values:
let i: i8 = Default::default(); let (x, y): (Option<String>, f64) = Default::default(); let (a, b, (c, d)): (i32, u32, (bool, bool)) = Default::default();
Making your own:
enum Kind { A, B, C, } impl Default for Kind { fn default() -> Self { Kind::A } }
Implementations on Foreign Types
impl<T> Default for SyncOnceCell<T>
[src]
impl<T> Default for SyncOnceCell<T>
[src]pub fn default() -> SyncOnceCell<T>
[src]
impl Default for RandomState
[src]
impl Default for RandomState
[src]pub fn default() -> RandomState
[src]
pub fn default() -> RandomState
[src]Constructs a new RandomState
.
impl Default for DefaultHasher
[src]
impl Default for DefaultHasher
[src]pub fn default() -> DefaultHasher
[src]
pub fn default() -> DefaultHasher
[src]Creates a new DefaultHasher
using new
.
See its documentation for more.
impl<A, B, C, D, E, F, G, H, I, J> Default for (A, B, C, D, E, F, G, H, I, J) where
C: Default,
E: Default,
A: Default,
B: Default,
F: Default,
I: Default,
G: Default,
D: Default,
H: Default,
J: Default,
[src]
impl<A, B, C, D, E, F, G, H, I, J> Default for (A, B, C, D, E, F, G, H, I, J) where
C: Default,
E: Default,
A: Default,
B: Default,
F: Default,
I: Default,
G: Default,
D: Default,
H: Default,
J: Default,
[src]impl<'_, T> Default for &'_ mut [T]
[src]
impl<'_, T> Default for &'_ mut [T]
[src]impl<A, B, C, D, E, F, G> Default for (A, B, C, D, E, F, G) where
C: Default,
E: Default,
A: Default,
B: Default,
F: Default,
G: Default,
D: Default,
[src]
impl<A, B, C, D, E, F, G> Default for (A, B, C, D, E, F, G) where
C: Default,
E: Default,
A: Default,
B: Default,
F: Default,
G: Default,
D: Default,
[src]impl<A, B, C, D, E, F, G, H> Default for (A, B, C, D, E, F, G, H) where
C: Default,
E: Default,
A: Default,
B: Default,
F: Default,
G: Default,
D: Default,
H: Default,
[src]
impl<A, B, C, D, E, F, G, H> Default for (A, B, C, D, E, F, G, H) where
C: Default,
E: Default,
A: Default,
B: Default,
F: Default,
G: Default,
D: Default,
H: Default,
[src]impl<A, B, C, D, E> Default for (A, B, C, D, E) where
C: Default,
E: Default,
A: Default,
B: Default,
D: Default,
[src]
impl<A, B, C, D, E> Default for (A, B, C, D, E) where
C: Default,
E: Default,
A: Default,
B: Default,
D: Default,
[src]impl<A, B, C, D, E, F, G, H, I> Default for (A, B, C, D, E, F, G, H, I) where
C: Default,
E: Default,
A: Default,
B: Default,
F: Default,
I: Default,
G: Default,
D: Default,
H: Default,
[src]
impl<A, B, C, D, E, F, G, H, I> Default for (A, B, C, D, E, F, G, H, I) where
C: Default,
E: Default,
A: Default,
B: Default,
F: Default,
I: Default,
G: Default,
D: Default,
H: Default,
[src]impl<A, B, C, D, E, F, G, H, I, J, K, L> Default for (A, B, C, D, E, F, G, H, I, J, K, L) where
C: Default,
E: Default,
A: Default,
B: Default,
F: Default,
K: Default,
I: Default,
G: Default,
D: Default,
H: Default,
J: Default,
L: Default,
[src]
impl<A, B, C, D, E, F, G, H, I, J, K, L> Default for (A, B, C, D, E, F, G, H, I, J, K, L) where
C: Default,
E: Default,
A: Default,
B: Default,
F: Default,
K: Default,
I: Default,
G: Default,
D: Default,
H: Default,
J: Default,
L: Default,
[src]impl<A, B, C, D> Default for (A, B, C, D) where
C: Default,
A: Default,
B: Default,
D: Default,
[src]
impl<A, B, C, D> Default for (A, B, C, D) where
C: Default,
A: Default,
B: Default,
D: Default,
[src]impl<A, B, C, D, E, F, G, H, I, J, K> Default for (A, B, C, D, E, F, G, H, I, J, K) where
C: Default,
E: Default,
A: Default,
B: Default,
F: Default,
K: Default,
I: Default,
G: Default,
D: Default,
H: Default,
J: Default,
[src]
impl<A, B, C, D, E, F, G, H, I, J, K> Default for (A, B, C, D, E, F, G, H, I, J, K) where
C: Default,
E: Default,
A: Default,
B: Default,
F: Default,
K: Default,
I: Default,
G: Default,
D: Default,
H: Default,
J: Default,
[src]impl<A, B, C, D, E, F> Default for (A, B, C, D, E, F) where
C: Default,
E: Default,
A: Default,
B: Default,
F: Default,
D: Default,
[src]
impl<A, B, C, D, E, F> Default for (A, B, C, D, E, F) where
C: Default,
E: Default,
A: Default,
B: Default,
F: Default,
D: Default,
[src]impl<T> Default for Box<T, Global> where
T: Default,
[src]
impl<T> Default for Box<T, Global> where
T: Default,
[src]impl<T> Default for LinkedList<T>
[src]
impl<T> Default for LinkedList<T>
[src]pub fn default() -> LinkedList<T>
[src]
pub fn default() -> LinkedList<T>
[src]Creates an empty LinkedList<T>
.
impl<T> Default for BinaryHeap<T> where
T: Ord,
[src]
impl<T> Default for BinaryHeap<T> where
T: Ord,
[src]pub fn default() -> BinaryHeap<T>
[src]
pub fn default() -> BinaryHeap<T>
[src]Creates an empty BinaryHeap<T>
.
impl Default for InstanceLimits
[src]
impl Default for InstanceLimits
[src]pub fn default() -> InstanceLimits
[src]
impl Default for ModuleLimits
[src]
impl Default for ModuleLimits
[src]pub fn default() -> ModuleLimits
[src]
impl Default for StoreLimits
[src]
impl Default for StoreLimits
[src]pub fn default() -> StoreLimits
[src]
impl Default for InstanceAllocationStrategy
[src]
impl Default for InstanceAllocationStrategy
[src]pub fn default() -> InstanceAllocationStrategy
[src]
impl Default for PoolingAllocationStrategy
[src]
impl Default for PoolingAllocationStrategy
[src]pub fn default() -> PoolingAllocationStrategy
[src]
impl<'a> Default for DisplayFunctionAnnotations<'a>
impl<'a> Default for DisplayFunctionAnnotations<'a>
pub fn default() -> DisplayFunctionAnnotations<'a>
impl Default for EvexInstruction
impl Default for EvexInstruction
Because some of the bit flags in the EVEX prefix are reversed and users of EvexInstruction
may
choose to skip setting fields, here we set some sane defaults. Note that:
- the first byte is always
0x62
but you will notice it at the end of the defaultbits
value implemented–remember the little-endian order - some bits are always set to certain values: bits 10-11 to 0, bit 18 to 1
- the other bits set correspond to reversed bits: R, X, B, R’ (byte 1), vvvv (byte 2), V’ (byte 3).
See the default_emission
test for what these defaults are equivalent to (e.g. using RAX,
unsetting the W bit, etc.)
pub fn default() -> EvexInstruction
impl<K, V> Default for SecondaryMap<K, V> where
K: EntityRef,
V: Clone + Default,
impl<K, V> Default for SecondaryMap<K, V> where
K: EntityRef,
V: Clone + Default,
pub fn default() -> SecondaryMap<K, V>
impl<T> Default for EntityList<T> where
T: EntityRef + ReservedValue,
impl<T> Default for EntityList<T> where
T: EntityRef + ReservedValue,
Create an empty list.
pub fn default() -> EntityList<T>
impl<T> Default for PackedOption<T> where
T: ReservedValue,
impl<T> Default for PackedOption<T> where
T: ReservedValue,
pub fn default() -> PackedOption<T>
pub fn default() -> PackedOption<T>
Create a default packed option representing None
.
impl Default for IgnoredAny
[src]
impl Default for IgnoredAny
[src]pub fn default() -> IgnoredAny
[src]
impl<W> Default for DebugLocLists<W> where
W: Default + Writer,
impl<W> Default for DebugLocLists<W> where
W: Default + Writer,
pub fn default() -> DebugLocLists<W>
impl<W> Default for DebugRngLists<W> where
W: Default + Writer,
impl<W> Default for DebugRngLists<W> where
W: Default + Writer,
pub fn default() -> DebugRngLists<W>
impl<'input, Endian> Default for EndianSlice<'input, Endian> where
Endian: Default + Endianity,
impl<'input, Endian> Default for EndianSlice<'input, Endian> where
Endian: Default + Endianity,
pub fn default() -> EndianSlice<'input, Endian>
impl<R> Default for UninitializedUnwindContext<R> where
R: Reader,
impl<R> Default for UninitializedUnwindContext<R> where
R: Reader,
pub fn default() -> UninitializedUnwindContext<R>
impl<T, S> Default for HashSet<T, S> where
S: Default,
impl<T, S> Default for HashSet<T, S> where
S: Default,
pub fn default() -> HashSet<T, S>
pub fn default() -> HashSet<T, S>
Creates an empty HashSet<T, S>
with the Default
value for the hasher.
impl<K, V, S> Default for HashMap<K, V, S> where
S: Default,
impl<K, V, S> Default for HashMap<K, V, S> where
S: Default,
pub fn default() -> HashMap<K, V, S>
pub fn default() -> HashMap<K, V, S>
Creates an empty HashMap<K, V, S>
, with the Default
value for the hasher.
impl<E> Default for CompressionHeader64<E> where
E: Default + Endian,
impl<E> Default for CompressionHeader64<E> where
E: Default + Endian,
pub fn default() -> CompressionHeader64<E>
impl<'data, Elf> Default for SymbolTable<'data, Elf> where
Elf: FileHeader,
impl<'data, Elf> Default for SymbolTable<'data, Elf> where
Elf: FileHeader,
pub fn default() -> SymbolTable<'data, Elf>
impl<T> Default for SymbolMap<T> where
T: Default + SymbolMapEntry,
impl<T> Default for SymbolMap<T> where
T: Default + SymbolMapEntry,
pub fn default() -> SymbolMap<T>
impl<'data, Mach> Default for SymbolTable<'data, Mach> where
Mach: MachHeader,
impl<'data, Mach> Default for SymbolTable<'data, Mach> where
Mach: MachHeader,
pub fn default() -> SymbolTable<'data, Mach>
impl<'data, Elf> Default for SectionTable<'data, Elf> where
Elf: Default + FileHeader,
<Elf as FileHeader>::SectionHeader: Default,
impl<'data, Elf> Default for SectionTable<'data, Elf> where
Elf: Default + FileHeader,
<Elf as FileHeader>::SectionHeader: Default,
pub fn default() -> SectionTable<'data, Elf>
impl<'data, E> Default for LoadCommandIterator<'data, E> where
E: Default + Endian,
impl<'data, E> Default for LoadCommandIterator<'data, E> where
E: Default + Endian,
pub fn default() -> LoadCommandIterator<'data, E>
impl<E> Default for CompressionHeader32<E> where
E: Default + Endian,
impl<E> Default for CompressionHeader32<E> where
E: Default + Endian,
pub fn default() -> CompressionHeader32<E>
impl Default for DecompressorOxide
impl Default for DecompressorOxide
pub fn default() -> DecompressorOxide
pub fn default() -> DecompressorOxide
Create a new tinfl_decompressor with all fields set to 0.
impl Default for CompressorOxide
impl Default for CompressorOxide
pub fn default() -> CompressorOxide
pub fn default() -> CompressorOxide
Initialize the compressor with a level of 4, zlib wrapper and the default strategy.
impl Default for DefaultOptions
[src]
impl Default for DefaultOptions
[src]pub fn default() -> DefaultOptions
[src]
Implementors
impl Default for PhantomPinned
1.33.0[src]
impl Default for PhantomPinned
1.33.0[src]pub fn default() -> PhantomPinned
[src]
impl Default for AtomicBool
[src]
impl Default for AtomicBool
[src]pub fn default() -> AtomicBool
[src]
pub fn default() -> AtomicBool
[src]Creates an AtomicBool
initialized to false
.
impl Default for AtomicIsize
[src]
impl Default for AtomicIsize
[src]pub fn default() -> AtomicIsize
[src]
impl Default for AtomicUsize
[src]
impl Default for AtomicUsize
[src]pub fn default() -> AtomicUsize
[src]
impl<'a> Default for CommentSyntax<'a>
[src]
impl<'a> Default for CommentSyntax<'a>
[src]pub fn default() -> CommentSyntax<'a>
[src]
impl<'a, T> Default for Documented<'a, T> where
T: Default,
[src]
impl<'a, T> Default for Documented<'a, T> where
T: Default,
[src]pub fn default() -> Documented<'a, T>
[src]
impl<H> Default for BuildHasherDefault<H>
1.7.0[src]
impl<H> Default for BuildHasherDefault<H>
1.7.0[src]pub fn default() -> BuildHasherDefault<H>
[src]
impl<T> Default for UnsafeCell<T> where
T: Default,
1.10.0[src]
impl<T> Default for UnsafeCell<T> where
T: Default,
1.10.0[src]pub fn default() -> UnsafeCell<T>
[src]
pub fn default() -> UnsafeCell<T>
[src]Creates an UnsafeCell
, with the Default
value for T.
impl<T> Default for PhantomData<T> where
T: ?Sized,
[src]
impl<T> Default for PhantomData<T> where
T: ?Sized,
[src]pub fn default() -> PhantomData<T>
[src]
impl<T> Default for ManuallyDrop<T> where
T: Default + ?Sized,
1.20.0[src]
impl<T> Default for ManuallyDrop<T> where
T: Default + ?Sized,
1.20.0[src]