pub fn default<T: Default>() -> T
🔬This is a nightly-only experimental API. (default_free_fn #73014)
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:


use std::default::default;

struct AppConfig {
    foo: FooConfig,
    bar: BarConfig,

struct FooConfig {
    foo: i32,

struct BarConfig {
    bar: f32,
    baz: u8,

fn main() {
    let options = AppConfig {
        foo: default(),
        bar: BarConfig {
            bar: 10.1,