Function core::default::default [−][src]
pub fn default<T: Default>() -> T
Expand description
Return the default value of a type according to the Default
trait.
The type to return is inferred from context; this is equivalent to
Default::default()
but shorter to type.
For example:
#![feature(default_free_fn)]
use std::default::default;
#[derive(Default)]
struct AppConfig {
foo: FooConfig,
bar: BarConfig,
}
#[derive(Default)]
struct FooConfig {
foo: i32,
}
#[derive(Default)]
struct BarConfig {
bar: f32,
baz: u8,
}
fn main() {
let options = AppConfig {
foo: default(),
bar: BarConfig {
bar: 10.1,
..default()
},
};
}
Run