Function bevy::prelude::default

pub fn default<T>() -> Twhere
    T: Default,
Expand description

An ergonomic abbreviation for Default::default() to make initializing structs easier. This is especially helpful when combined with “struct update syntax”.

use bevy_utils::default;

struct Foo {
  a: usize,
  b: usize,
  c: usize,

// Normally you would initialize a struct with defaults using "struct update syntax"
// combined with `Default::default()`. This example sets `Foo::bar` to 10 and the remaining
// values to their defaults.
let foo = Foo {
  a: 10,

// But now you can do this, which is equivalent:
let foo = Foo {
  a: 10,