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
//! Internal macros for reducing boilerplate across type implementations.
/// Adds a `new()` constructor that takes required fields and defaults the rest.
///
/// Requires `Default` to be derived on the target struct. Required fields use
/// `impl Into<T>` for ergonomic construction.
///
/// # Usage
///
/// ```ignore
/// impl_new!(BotCommand { command: String, description: String });
/// ```
///
/// Generates:
///
/// ```ignore
/// impl BotCommand {
/// pub fn new(command: impl Into<String>, description: impl Into<String>) -> Self {
/// Self {
/// command: command.into(),
/// description: description.into(),
/// ..Default::default()
/// }
/// }
/// }
/// ```