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
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
const: unstable · sourceimpl<T> Default for SyncOnceCell<T>
impl<T> Default for SyncOnceCell<T>
const: unstable · sourcefn default() -> SyncOnceCell<T>
fn default() -> SyncOnceCell<T>
Creates a new empty cell.
Example
#![feature(once_cell)]
use std::lazy::SyncOnceCell;
fn main() {
assert_eq!(SyncOnceCell::<()>::new(), SyncOnceCell::default());
}
1.17.0 · sourceimpl Default for Box<CStr, Global>
impl Default for Box<CStr, Global>
fn default() -> Box<CStr, Global>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
1.17.0 · sourceimpl Default for Box<OsStr, Global>
impl Default for Box<OsStr, Global>
fn default() -> Box<OsStr, Global>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
sourceimpl<A, B, C, D, E> Default for (A, B, C, D, E) where
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
impl<A, B, C, D, E> Default for (A, B, C, D, E) where
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
sourceimpl<A, B, C, D, E, F> Default for (A, B, C, D, E, F) where
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
F: Default,
impl<A, B, C, D, E, F> Default for (A, B, C, D, E, F) where
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
F: Default,
sourceimpl<A, B, C, D, E, F, G, H> Default for (A, B, C, D, E, F, G, H) where
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
F: Default,
G: Default,
H: Default,
impl<A, B, C, D, E, F, G, H> Default for (A, B, C, D, E, F, G, H) where
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
F: Default,
G: Default,
H: Default,
sourceimpl<A, B, C, D, E, F, G> Default for (A, B, C, D, E, F, G) where
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
F: Default,
G: Default,
impl<A, B, C, D, E, F, G> Default for (A, B, C, D, E, F, G) where
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
F: Default,
G: Default,
sourceimpl<A, B, C, D, E, F, G, H, I> Default for (A, B, C, D, E, F, G, H, I) where
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
F: Default,
G: Default,
H: Default,
I: Default,
impl<A, B, C, D, E, F, G, H, I> Default for (A, B, C, D, E, F, G, H, I) where
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
F: Default,
G: Default,
H: Default,
I: Default,
sourceimpl<A, B, C, D> Default for (A, B, C, D) where
A: Default,
B: Default,
C: Default,
D: Default,
impl<A, B, C, D> Default for (A, B, C, D) where
A: Default,
B: Default,
C: Default,
D: Default,
sourceimpl<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
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
F: Default,
G: Default,
H: Default,
I: Default,
J: Default,
K: Default,
L: Default,
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
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
F: Default,
G: Default,
H: Default,
I: Default,
J: Default,
K: Default,
L: Default,
sourceimpl<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
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
F: Default,
G: Default,
H: Default,
I: Default,
J: Default,
K: Default,
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
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
F: Default,
G: Default,
H: Default,
I: Default,
J: Default,
K: Default,
1.5.0 (const: unstable) · sourceimpl<'_, T> Default for &'_ mut [T]
impl<'_, T> Default for &'_ mut [T]
sourceimpl<A, B, C, D, E, F, G, H, I, J> Default for (A, B, C, D, E, F, G, H, I, J) where
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
F: Default,
G: Default,
H: Default,
I: Default,
J: Default,
impl<A, B, C, D, E, F, G, H, I, J> Default for (A, B, C, D, E, F, G, H, I, J) where
A: Default,
B: Default,
C: Default,
D: Default,
E: Default,
F: Default,
G: Default,
H: Default,
I: Default,
J: Default,
sourceimpl<T> Default for LinkedList<T>
impl<T> Default for LinkedList<T>
sourcefn default() -> LinkedList<T>
fn default() -> LinkedList<T>
Creates an empty LinkedList<T>
.
sourceimpl<T> Default for Box<T, Global> where
T: Default,
impl<T> Default for Box<T, Global> where
T: Default,
sourcefn default() -> Box<T, Global>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn default() -> Box<T, Global>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Creates a Box<T>
, with the Default
value for T.
1.17.0 · sourceimpl Default for Box<str, Global>
impl Default for Box<str, Global>
fn default() -> Box<str, Global>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
sourceimpl<T> Default for Box<[T], Global>
impl<T> Default for Box<[T], Global>
fn default() -> Box<[T], Global>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
sourceimpl<T> Default for BinaryHeap<T> where
T: Ord,
impl<T> Default for BinaryHeap<T> where
T: Ord,
sourcefn default() -> BinaryHeap<T>
fn default() -> BinaryHeap<T>
Creates an empty BinaryHeap<T>
.
impl<BlockSize> Default for BlockBuffer<BlockSize> where
BlockSize: Default + ArrayLength<u8>,
impl<BlockSize> Default for BlockBuffer<BlockSize> where
BlockSize: Default + ArrayLength<u8>,
fn default() -> BlockBuffer<BlockSize>
impl Default for Sha512Trunc224
impl Default for Sha512Trunc224
impl Default for Sha512Trunc256
impl Default for Sha512Trunc256
sourceimpl<FORMAT, STRICTNESS> Default for DurationMilliSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for DurationMilliSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> DurationMilliSeconds<FORMAT, STRICTNESS>
sourceimpl<FORMAT, STRICTNESS> Default for TimestampMicroSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for TimestampMicroSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> TimestampMicroSeconds<FORMAT, STRICTNESS>
sourceimpl<FORMAT, STRICTNESS> Default for TimestampSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for TimestampSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> TimestampSecondsWithFrac<FORMAT, STRICTNESS>
sourceimpl Default for DisplayFromStr
impl Default for DisplayFromStr
fn default() -> DisplayFromStr
sourceimpl<FORMAT, STRICTNESS> Default for DurationSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for DurationSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> DurationSecondsWithFrac<FORMAT, STRICTNESS>
sourceimpl<FORMAT, STRICTNESS> Default for TimestampMilliSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for TimestampMilliSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> TimestampMilliSecondsWithFrac<FORMAT, STRICTNESS>
sourceimpl<FORMAT, STRICTNESS> Default for DurationNanoSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for DurationNanoSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> DurationNanoSecondsWithFrac<FORMAT, STRICTNESS>
sourceimpl Default for NoneAsEmptyString
impl Default for NoneAsEmptyString
fn default() -> NoneAsEmptyString
sourceimpl<FORMAT, STRICTNESS> Default for TimestampNanoSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for TimestampNanoSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> TimestampNanoSecondsWithFrac<FORMAT, STRICTNESS>
sourceimpl<FORMAT, STRICTNESS> Default for DurationMicroSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for DurationMicroSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> DurationMicroSeconds<FORMAT, STRICTNESS>
sourceimpl<Sep, T> Default for StringWithSeparator<Sep, T> where
Sep: Default,
T: Default,
impl<Sep, T> Default for StringWithSeparator<Sep, T> where
Sep: Default,
T: Default,
fn default() -> StringWithSeparator<Sep, T>
sourceimpl<T> Default for DefaultOnError<T> where
T: Default,
impl<T> Default for DefaultOnError<T> where
T: Default,
fn default() -> DefaultOnError<T>
sourceimpl<FORMAT, STRICTNESS> Default for TimestampMicroSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for TimestampMicroSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> TimestampMicroSecondsWithFrac<FORMAT, STRICTNESS>
sourceimpl<FORMAT, STRICTNESS> Default for DurationMilliSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for DurationMilliSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> DurationMilliSecondsWithFrac<FORMAT, STRICTNESS>
sourceimpl<FORMAT, STRICTNESS> Default for DurationMicroSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for DurationMicroSecondsWithFrac<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> DurationMicroSecondsWithFrac<FORMAT, STRICTNESS>
sourceimpl<FORMAT, STRICTNESS> Default for DurationNanoSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for DurationNanoSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> DurationNanoSeconds<FORMAT, STRICTNESS>
sourceimpl<FORMAT, STRICTNESS> Default for TimestampSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for TimestampSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> TimestampSeconds<FORMAT, STRICTNESS>
sourceimpl<FORMAT, STRICTNESS> Default for TimestampNanoSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for TimestampNanoSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> TimestampNanoSeconds<FORMAT, STRICTNESS>
sourceimpl Default for BytesOrString
impl Default for BytesOrString
fn default() -> BytesOrString
sourceimpl<FORMAT, STRICTNESS> Default for TimestampMilliSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for TimestampMilliSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> TimestampMilliSeconds<FORMAT, STRICTNESS>
sourceimpl Default for CommaSeparator
impl Default for CommaSeparator
fn default() -> CommaSeparator
sourceimpl<FORMAT, STRICTNESS> Default for DurationSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
impl<FORMAT, STRICTNESS> Default for DurationSeconds<FORMAT, STRICTNESS> where
FORMAT: Default + Format,
STRICTNESS: Default + Strictness,
fn default() -> DurationSeconds<FORMAT, STRICTNESS>
sourceimpl<T> Default for TryFromInto<T> where
T: Default,
impl<T> Default for TryFromInto<T> where
T: Default,
fn default() -> TryFromInto<T>
sourceimpl<T> Default for DefaultOnNull<T> where
T: Default,
impl<T> Default for DefaultOnNull<T> where
T: Default,
fn default() -> DefaultOnNull<T>
sourceimpl Default for PreferMany
impl Default for PreferMany
fn default() -> PreferMany
sourceimpl Default for SpaceSeparator
impl Default for SpaceSeparator
fn default() -> SpaceSeparator
sourceimpl<T> Default for VecSkipError<T> where
T: Default,
impl<T> Default for VecSkipError<T> where
T: Default,
fn default() -> VecSkipError<T>
impl Default for WeekNumberRepr
impl Default for WeekNumberRepr
Creates a modifier that indicates that the value uses the Iso
representation.
fn default() -> WeekNumberRepr
impl Default for WeekdayRepr
impl Default for WeekdayRepr
Creates a modifier that indicates the value uses the Long
representation.
fn default() -> WeekdayRepr
impl Default for Minute
impl Default for Minute
Creates a modifier that indicates the value is padded with zeroes.
fn default() -> Minute
impl Default for Padding
impl Default for Padding
Creates a modifier that indicates the value is padded with zeroes.
fn default() -> Padding
impl Default for Hour
impl Default for Hour
Creates a modifier that indicates the value is padded with zeroes and has the 24-hour representation.
fn default() -> Hour
impl Default for Month
impl Default for Month
Creates an instance of this type that indicates the value uses the
Numerical
representation, is padded with zeroes,
and is case-sensitive when parsing.
fn default() -> Month
impl Default for OffsetSecond
impl Default for OffsetSecond
Creates a modifier that indicates the value is padded with zeroes.
fn default() -> OffsetSecond
impl Default for Second
impl Default for Second
Creates a modifier that indicates the value is padded with zeroes.
fn default() -> Second
impl Default for Subsecond
impl Default for Subsecond
Creates a modifier that indicates the stringified value contains one or more digits.
fn default() -> Subsecond
impl Default for WeekNumber
impl Default for WeekNumber
Creates a modifier that indicates that the value is padded with zeroes
and uses the Iso
representation.
fn default() -> WeekNumber
impl Default for Year
impl Default for Year
Creates a modifier that indicates the value uses the Full
representation, is padded with zeroes, uses the Gregorian calendar as its
base, and only includes the year’s sign if necessary.
fn default() -> Year
impl Default for SubsecondDigits
impl Default for SubsecondDigits
Creates a modifier that indicates the stringified value contains one or more digits.
fn default() -> SubsecondDigits
impl Default for Ordinal
impl Default for Ordinal
Creates a modifier that indicates the value is padded with zeroes.
fn default() -> Ordinal
impl Default for OffsetMinute
impl Default for OffsetMinute
Creates a modifier that indicates the value is padded with zeroes.
fn default() -> OffsetMinute
impl Default for OffsetHour
impl Default for OffsetHour
Creates a modifier that indicates the value uses the +
sign for all positive values
and is padded with zeroes.
fn default() -> OffsetHour
impl Default for YearRepr
impl Default for YearRepr
Creates a modifier that indicates the value uses the Full
representation.
fn default() -> YearRepr
impl Default for Day
impl Default for Day
Creates a modifier that indicates the value is padded with zeroes.
fn default() -> Day
impl Default for MonthRepr
impl Default for MonthRepr
Creates a modifier that indicates the value uses the
Numerical
representation.
fn default() -> MonthRepr
impl Default for Period
impl Default for Period
Creates a modifier that indicates the value uses the upper-case representation and is case-sensitive when parsing.
fn default() -> Period
impl Default for Weekday
impl Default for Weekday
Creates a modifier that indicates the value uses the Long
representation and is case-sensitive when parsing. If the representation is changed to a
numerical one, the instance defaults to one-based indexing.
fn default() -> Weekday
impl Default for Style
impl Default for Style
fn default() -> Style
fn default() -> Style
Returns a style with no properties set. Formatting text using this style returns the exact same text.
use ansi_term::Style;
assert_eq!(None, Style::default().foreground);
assert_eq!(None, Style::default().background);
assert_eq!(false, Style::default().is_bold);
assert_eq!("txt", Style::default().paint("txt").to_string());
impl<I, A> Default for Box<IndexSlice<I, [A]>, Global> where
I: Idx,
impl<I, A> Default for Box<IndexSlice<I, [A]>, Global> where
I: Idx,
fn default() -> Box<IndexSlice<I, [A]>, Global>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
impl<R, S> Default for UnwindTableRow<R, S> where
R: Reader,
S: UnwindContextStorage<R>,
impl<R, S> Default for UnwindTableRow<R, S> where
R: Reader,
S: UnwindContextStorage<R>,
fn default() -> UnwindTableRow<R, S>
impl<'input, Endian> Default for EndianSlice<'input, Endian> where
Endian: Default + Endianity,
impl<'input, Endian> Default for EndianSlice<'input, Endian> where
Endian: Default + Endianity,
fn default() -> EndianSlice<'input, Endian>
impl<R, A> Default for UnwindContext<R, A> where
R: Reader,
A: UnwindContextStorage<R>,
impl<R, A> Default for UnwindContext<R, A> where
R: Reader,
A: UnwindContextStorage<R>,
fn default() -> UnwindContext<R, A>
impl<'data, Elf, R> Default for SymbolTable<'data, Elf, R> where
Elf: FileHeader,
R: ReadRef<'data>,
impl<'data, Elf, R> Default for SymbolTable<'data, Elf, R> where
Elf: FileHeader,
R: ReadRef<'data>,
fn default() -> SymbolTable<'data, Elf, R>
impl<'data, E> Default for LoadCommandIterator<'data, E> where
E: Default + Endian,
impl<'data, E> Default for LoadCommandIterator<'data, E> where
E: Default + Endian,
fn default() -> LoadCommandIterator<'data, E>
impl<'data, Mach, R> Default for SymbolTable<'data, Mach, R> where
Mach: MachHeader,
R: ReadRef<'data>,
impl<'data, Mach, R> Default for SymbolTable<'data, Mach, R> where
Mach: MachHeader,
R: ReadRef<'data>,
fn default() -> SymbolTable<'data, Mach, R>
impl<'data, R> Default for StringTable<'data, R> where
R: ReadRef<'data>,
impl<'data, R> Default for StringTable<'data, R> where
R: ReadRef<'data>,
fn default() -> StringTable<'data, R>
impl<'data, Elf, R> Default for SectionTable<'data, Elf, R> where
Elf: Default + FileHeader,
R: Default + ReadRef<'data>,
<Elf as FileHeader>::SectionHeader: Default,
impl<'data, Elf, R> Default for SectionTable<'data, Elf, R> where
Elf: Default + FileHeader,
R: Default + ReadRef<'data>,
<Elf as FileHeader>::SectionHeader: Default,
fn default() -> SectionTable<'data, Elf, R>
impl<E> Default for CompressionHeader32<E> where
E: Default + Endian,
impl<E> Default for CompressionHeader32<E> where
E: Default + Endian,
fn default() -> CompressionHeader32<E>
impl<E> Default for CompressionHeader64<E> where
E: Default + Endian,
impl<E> Default for CompressionHeader64<E> where
E: Default + Endian,
fn default() -> CompressionHeader64<E>
impl<'data> Default for RelocationBlockIterator<'data>
impl<'data> Default for RelocationBlockIterator<'data>
fn default() -> RelocationBlockIterator<'data>
impl<'data, Elf> Default for VersionTable<'data, Elf> where
Elf: FileHeader,
impl<'data, Elf> Default for VersionTable<'data, Elf> where
Elf: FileHeader,
fn default() -> VersionTable<'data, Elf>
impl Default for CompressorOxide
impl Default for CompressorOxide
fn default() -> CompressorOxide
fn default() -> CompressorOxide
Initialize the compressor with a level of 4, zlib wrapper and the default strategy.
impl Default for DecompressorOxide
impl Default for DecompressorOxide
fn default() -> DecompressorOxide
fn default() -> DecompressorOxide
Create a new tinfl_decompressor with all fields set to 0.
sourceimpl Default for Compression
impl Default for Compression
fn default() -> Compression
sourceimpl Default for Compression
impl Default for Compression
sourcefn default() -> Compression
fn default() -> Compression
Choose the default compression, a balance between speed and size.
sourceimpl Default for ParamsString
impl Default for ParamsString
fn default() -> ParamsString
impl Default for Config
impl Default for Config
The defaults are that of https://url.spec.whatwg.org/#idna
fn default() -> Config
impl<P, Container> Default for ImageBuffer<P, Container> where
P: Pixel,
Container: Default,
impl<P, Container> Default for ImageBuffer<P, Container> where
P: Pixel,
Container: Default,
fn default() -> ImageBuffer<P, Container>
impl Default for PixelDensity
impl Default for PixelDensity
fn default() -> PixelDensity
fn default() -> PixelDensity
Returns a pixel density with a pixel aspect ratio of 1
impl Default for Transformations
impl Default for Transformations
Instantiate the default transformations, the identity transform.
fn default() -> Transformations
impl Default for DecompressorOxide
impl Default for DecompressorOxide
fn default() -> DecompressorOxide
fn default() -> DecompressorOxide
Create a new tinfl_decompressor with all fields set to 0.
impl Default for CompressorOxide
impl Default for CompressorOxide
fn default() -> CompressorOxide
fn default() -> CompressorOxide
Initialize the compressor with a level of 4, zlib wrapper and the default strategy.
impl Default for CompressionOptions
impl Default for CompressionOptions
fn default() -> CompressionOptions
fn default() -> CompressionOptions
Returns the options describing the default compression level.
sourceimpl<'a> Default for ArgMatches<'a>
impl<'a> Default for ArgMatches<'a>
fn default() -> ArgMatches<'a>
sourceimpl Default for ClientBuilder
impl Default for ClientBuilder
fn default() -> ClientBuilder
sourceimpl Default for ClientBuilder
impl Default for ClientBuilder
fn default() -> ClientBuilder
sourceimpl Default for StatusCode
impl Default for StatusCode
fn default() -> StatusCode
sourceimpl Default for Extensions
impl Default for Extensions
fn default() -> Extensions
impl<F> Default for OptionFuture<F>
impl<F> Default for OptionFuture<F>
sourceimpl<D, E> Default for UnsyncBoxBody<D, E> where
D: 'static + Buf,
impl<D, E> Default for UnsyncBoxBody<D, E> where
D: 'static + Buf,
fn default() -> UnsyncBoxBody<D, E>
impl Default for MissedTickBehavior
impl Default for MissedTickBehavior
fn default() -> MissedTickBehavior
fn default() -> MissedTickBehavior
Returns [MissedTickBehavior::Burst
].
For most usecases, the Burst
strategy is what is desired.
Additionally, to preserve backwards compatibility, the Burst
strategy must be the default. For these reasons,
[MissedTickBehavior::Burst
] is the default for [MissedTickBehavior
].
See Burst
for more details.
impl Default for LocalSet
impl Default for LocalSet
impl Default for Client<HttpConnector<GaiResolver>, Body>
impl Default for Client<HttpConnector<GaiResolver>, Body>
fn default() -> Client<HttpConnector<GaiResolver>, Body>
sourceimpl Default for NoSubscriber
impl Default for NoSubscriber
fn default() -> NoSubscriber
impl<T, S, A> Default for HashSet<T, S, A> where
S: Default,
A: Default + Allocator + Clone,
impl<T, S, A> Default for HashSet<T, S, A> where
S: Default,
A: Default + Allocator + Clone,
fn default() -> HashSet<T, S, A>
fn default() -> HashSet<T, S, A>
Creates an empty HashSet<T, S>
with the Default
value for the hasher.
impl<T, A> Default for RawTable<T, A> where
A: Allocator + Clone + Default,
impl<T, A> Default for RawTable<T, A> where
A: Allocator + Clone + Default,
fn default() -> RawTable<T, A>
impl<K, V, S, A> Default for HashMap<K, V, S, A> where
S: Default,
A: Default + Allocator + Clone,
impl<K, V, S, A> Default for HashMap<K, V, S, A> where
S: Default,
A: Default + Allocator + Clone,
fn default() -> HashMap<K, V, S, A>
fn default() -> HashMap<K, V, S, A>
Creates an empty HashMap<K, V, S, A>
, with the Default
value for the hasher and allocator.
sourceimpl Default for ExtendedKeyUsage
impl Default for ExtendedKeyUsage
fn default() -> ExtendedKeyUsage
sourceimpl Default for BasicConstraints
impl Default for BasicConstraints
fn default() -> BasicConstraints
sourceimpl Default for SubjectKeyIdentifier
impl Default for SubjectKeyIdentifier
fn default() -> SubjectKeyIdentifier
sourceimpl Default for AuthorityKeyIdentifier
impl Default for AuthorityKeyIdentifier
fn default() -> AuthorityKeyIdentifier
sourceimpl Default for SubjectAlternativeName
impl Default for SubjectAlternativeName
fn default() -> SubjectAlternativeName
sourceimpl<T> Default for HttpsConnector<T> where
T: Default,
impl<T> Default for HttpsConnector<T> where
T: Default,
fn default() -> HttpsConnector<T>
Implementors
impl Default for AggregatedIE
impl Default for AssetUrlKey
impl Default for OccultationKindGeneral<(OccDisplacement, ZCoord)>
impl Default for PathResolveContext
impl Default for PathResolveMethod
impl Default for PieceAngle
impl Default for PieceMoveable
impl Default for PresentationLayout
impl Default for ErrorChannel
impl Default for Value
The default value is Value::Null
.
This is useful for handling omitted Value
fields when deserializing.
Examples
use serde_json::Value;
#[derive(Deserialize)]
struct Settings {
level: i32,
#[serde(default)]
extras: Value,
}
let data = r#" { "level": 42 } "#;
let s: Settings = serde_json::from_str(data)?;
assert_eq!(s.level, 42);
assert_eq!(s.extras, Value::Null);
impl Default for otter_api_tests::shapelib::BigEndian
impl Default for otter_api_tests::shapelib::LittleEndian
impl Default for ProgressUpdateMode
impl Default for PieceLabelPlace
impl Default for Target
impl Default for TimestampPrecision
The default timestamp precision is seconds.