bevy_utils/
default.rs

1/// An ergonomic abbreviation for [`Default::default()`] to make initializing structs easier.
2/// This is especially helpful when combined with ["struct update syntax"](https://doc.rust-lang.org/book/ch05-01-defining-structs.html#creating-instances-from-other-instances-with-struct-update-syntax).
3/// ```
4/// use bevy_utils::default;
5///
6/// #[derive(Default)]
7/// struct Foo {
8///   a: usize,
9///   b: usize,
10///   c: usize,
11/// }
12///
13/// // Normally you would initialize a struct with defaults using "struct update syntax"
14/// // combined with `Default::default()`. This example sets `Foo::bar` to 10 and the remaining
15/// // values to their defaults.
16/// let foo = Foo {
17///   a: 10,
18///   ..Default::default()
19/// };
20///
21/// // But now you can do this, which is equivalent:
22/// let foo = Foo {
23///   a: 10,
24///   ..default()
25/// };
26/// ```
27#[inline]
28pub fn default<T: Default>() -> T {
29    Default::default()
30}