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
use ;
use maskable_atomic_impl;
use TokenStream;
/// Derive `Maskable` for the type.
///
/// The type must be one of the following types:
/// - A unit-like enum.
/// - An enum where each variant has exactly one unnamed associated field. The associated field must
/// implement `Maskable`.
/// - A struct with named fields, where the type of each field must implement `Maskable`.
/// Derive `OptionMaskable` for the type.
///
/// The type must be one of the following types:
/// - A unit-like enum.
/// - An enum where each variant has exactly one unnamed associated field. The associated field must
/// implement `SelfMaskable` and `Default`.
/// - A struct that implements `Default` and `SelfMaskable`.
/// Derive `SelfMaskable` for the type.
///
/// The type must be one of the following types:
/// - A unit-like enum that implements `Default` and `PartialEqual`.
/// - A struct with named fields, where the type of each field must implement `Default`,
/// `PartialEqual`, and `SelfMaskable`.
/// Treat the type as an atomic value and Implement `Maskable`, `OptionMaskable`, `SelfMaskable`
/// for the type.
///
/// This means the value of this type can only be selected as a whole or not selected at all.
///
/// You can override the default implementation of `update_as_field` and `merge` if needed.
///
/// ### Example:
/// ```ignore
/// maskable_atomic!(impl bool {});
///
/// maskable_atomic!(
/// impl<T> Vec<T> {
/// // Omit this if you don't want to override the default implementation.
/// fn update_as_field(&mut self, source: Self, _mask: &Self::Mask, options: &UpdateOptions) {
/// self.merge(source, options);
/// }
///
/// // Omit this if you don't want to override the default implementation.
/// fn merge(&mut self, source: Self, options: &UpdateOptions) {
/// if options.replace_repeated {
/// *self = source;
/// return;
/// }
///
/// self.extend(source);
/// }
/// }
/// );
/// ```