1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! A *shorter* way to write default. Provide :
//!
//! - `___()` as a shorthand for `Default::default()`
//! - `i32::___()` instead of `i32::default()`
//!
//! Based on the [internals Rust discussion](https://internals.rust-lang.org/t/could-we-have-std-default/8756)
//!
//! Also check the [Defaults crate](https://github.com/dpc/rust-default) which use `default()` instead of `Default::default()`
/// `___()` is a shorthand for `Default::default()`
///
/// # Examples
///
/// ```
/// use hexga_core::prelude::*;
///
/// let b : i32 = Default::default(); // Default Rust
/// let a : i32 = ___(); // Now
/// assert_eq!(a, b);
/// ```
///
/// Can also be used with function :
///
/// ```ignore
/// let a = f(Default::default()); // Default Rust
/// let b = f(___()); // Now
/// assert_eq!(a, b);
/// ```
///
/// Can also be used to initialize complex Rust struct when implementing the `Default` trait :
///
/// ```ignore
/// impl Default for ComplexStruct {
/// fn default() -> Self {
/// Self { a : ___(), b : ___(), c : ___(), vec : vec![0] }
/// // instead of
/// // Self { a : Default::default(), b : Default::default(), c : Default::default(), vec : vec![0] }
/// }
/// }
/// ````
///
/// And also to partially initialize a struct
///
/// ```ignore
/// let a = BigStruct { x : 42, y : 64, ..Default::default() };
/// let b = BigStruct { x : 42, y : 64, ..___() };
/// assert_eq!(a, b);
/// ```
/// Uniform syntax : `MyStruct::___()` instead of `MyStruct::default()`