MCPcopy Create free account
hub / github.com/bitflags/bitflags / from_name

Method from_name

src/traits.rs:212–225  ·  view source on GitHub ↗

Get a flags value with the bits of a flag with the given name set. This method will return `None` if `name` is empty or doesn't correspond to any named flag.

(name: &str)

Source from the content-addressed store, hash-verified

210 /// This method will return `None` if `name` is empty or doesn't
211 /// correspond to any named flag.
212 fn from_name(name: &str) -> Option<Self> {
213 // Don't parse empty names as empty flags
214 if name.is_empty() {
215 return None;
216 }
217
218 for flag in Self::FLAGS {
219 if flag.name() == name {
220 return Some(Self::from_bits_retain(flag.value().bits()));
221 }
222 }
223
224 None
225 }
226
227 /// Yield a set of contained flags values.
228 ///

Callers

nothing calls this directly

Implementers 2

macro_free.rsexamples/macro_free.rs
custom_bits_type.rsexamples/custom_bits_type.rs

Calls 4

is_emptyMethod · 0.80
nameMethod · 0.80
valueMethod · 0.80
bitsMethod · 0.45

Tested by

no test coverage detected