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