@@ -127,22 +127,26 @@ macro_rules! bitflags {
127
127
128
128
impl $BitFlags {
129
129
/// Returns an empty set of flags.
130
+ #[ inline]
130
131
pub fn empty( ) -> $BitFlags {
131
132
$BitFlags { bits: 0 }
132
133
}
133
134
134
135
/// Returns the set containing all flags.
136
+ #[ inline]
135
137
pub fn all( ) -> $BitFlags {
136
138
$BitFlags { bits: $( $value) |+ }
137
139
}
138
140
139
141
/// Returns the raw value of the flags currently stored.
142
+ #[ inline]
140
143
pub fn bits( & self ) -> $T {
141
144
self . bits
142
145
}
143
146
144
147
/// Convert from underlying bit representation, unless that
145
148
/// representation contains bits that do not correspond to a flag.
149
+ #[ inline]
146
150
pub fn from_bits( bits: $T) -> :: std:: option:: Option <$BitFlags> {
147
151
if ( bits & !$BitFlags:: all( ) . bits( ) ) != 0 {
148
152
:: std:: option:: None
@@ -153,21 +157,25 @@ macro_rules! bitflags {
153
157
154
158
/// Convert from underlying bit representation, dropping any bits
155
159
/// that do not correspond to flags.
160
+ #[ inline]
156
161
pub fn from_bits_truncate( bits: $T) -> $BitFlags {
157
162
$BitFlags { bits: bits } & $BitFlags:: all( )
158
163
}
159
164
160
165
/// Returns `true` if no flags are currently stored.
166
+ #[ inline]
161
167
pub fn is_empty( & self ) -> bool {
162
168
* self == $BitFlags:: empty( )
163
169
}
164
170
165
171
/// Returns `true` if all flags are currently set.
172
+ #[ inline]
166
173
pub fn is_all( & self ) -> bool {
167
174
* self == $BitFlags:: all( )
168
175
}
169
176
170
177
/// Returns `true` if there are flags common to both `self` and `other`.
178
+ #[ inline]
171
179
pub fn intersects( & self , other: $BitFlags) -> bool {
172
180
!( self & other) . is_empty( )
173
181
}
@@ -179,16 +187,19 @@ macro_rules! bitflags {
179
187
}
180
188
181
189
/// Inserts the specified flags in-place.
190
+ #[ inline]
182
191
pub fn insert( & mut self , other: $BitFlags) {
183
192
self . bits |= other. bits;
184
193
}
185
194
186
195
/// Removes the specified flags in-place.
196
+ #[ inline]
187
197
pub fn remove( & mut self , other: $BitFlags) {
188
198
self . bits &= !other. bits;
189
199
}
190
200
191
201
/// Toggles the specified flags in-place.
202
+ #[ inline]
192
203
pub fn toggle( & mut self , other: $BitFlags) {
193
204
self . bits ^= other. bits;
194
205
}
0 commit comments