Skip to content

Commit c7c342d

Browse files
committed
auto merge of #18103 : pcwalton/rust/bitflags-inline, r=thestinger
Servo really wants this. r? @nick29581
2 parents 4b064a5 + 416e6ec commit c7c342d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/libstd/bitflags.rs

+11
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,26 @@ macro_rules! bitflags {
127127

128128
impl $BitFlags {
129129
/// Returns an empty set of flags.
130+
#[inline]
130131
pub fn empty() -> $BitFlags {
131132
$BitFlags { bits: 0 }
132133
}
133134

134135
/// Returns the set containing all flags.
136+
#[inline]
135137
pub fn all() -> $BitFlags {
136138
$BitFlags { bits: $($value)|+ }
137139
}
138140

139141
/// Returns the raw value of the flags currently stored.
142+
#[inline]
140143
pub fn bits(&self) -> $T {
141144
self.bits
142145
}
143146

144147
/// Convert from underlying bit representation, unless that
145148
/// representation contains bits that do not correspond to a flag.
149+
#[inline]
146150
pub fn from_bits(bits: $T) -> ::std::option::Option<$BitFlags> {
147151
if (bits & !$BitFlags::all().bits()) != 0 {
148152
::std::option::None
@@ -153,21 +157,25 @@ macro_rules! bitflags {
153157

154158
/// Convert from underlying bit representation, dropping any bits
155159
/// that do not correspond to flags.
160+
#[inline]
156161
pub fn from_bits_truncate(bits: $T) -> $BitFlags {
157162
$BitFlags { bits: bits } & $BitFlags::all()
158163
}
159164

160165
/// Returns `true` if no flags are currently stored.
166+
#[inline]
161167
pub fn is_empty(&self) -> bool {
162168
*self == $BitFlags::empty()
163169
}
164170

165171
/// Returns `true` if all flags are currently set.
172+
#[inline]
166173
pub fn is_all(&self) -> bool {
167174
*self == $BitFlags::all()
168175
}
169176

170177
/// Returns `true` if there are flags common to both `self` and `other`.
178+
#[inline]
171179
pub fn intersects(&self, other: $BitFlags) -> bool {
172180
!(self & other).is_empty()
173181
}
@@ -179,16 +187,19 @@ macro_rules! bitflags {
179187
}
180188

181189
/// Inserts the specified flags in-place.
190+
#[inline]
182191
pub fn insert(&mut self, other: $BitFlags) {
183192
self.bits |= other.bits;
184193
}
185194

186195
/// Removes the specified flags in-place.
196+
#[inline]
187197
pub fn remove(&mut self, other: $BitFlags) {
188198
self.bits &= !other.bits;
189199
}
190200

191201
/// Toggles the specified flags in-place.
202+
#[inline]
192203
pub fn toggle(&mut self, other: $BitFlags) {
193204
self.bits ^= other.bits;
194205
}

0 commit comments

Comments
 (0)