146 lines
37 KiB
HTML
146 lines
37 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A set of defined flags using a bits type as storage."><title>Flags in bitflags - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="bitflags" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Flags</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../bitflags/index.html">bitflags</a><span class="version">2.11.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Flags</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#implementing-flags" title="Implementing `Flags`">Implementing <code>Flags</code></a></li><li><a href="#using-flags" title="Using `Flags`">Using <code>Flags</code></a></li></ul><h3><a href="#required-associated-consts">Required Associated Constants</a></h3><ul class="block"><li><a href="#associatedconstant.FLAGS" title="FLAGS">FLAGS</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Bits" title="Bits">Bits</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.bits" title="bits">bits</a></li><li><a href="#tymethod.from_bits_retain" title="from_bits_retain">from_bits_retain</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.all" title="all">all</a></li><li><a href="#method.clear" title="clear">clear</a></li><li><a href="#method.complement" title="complement">complement</a></li><li><a href="#method.contains" title="contains">contains</a></li><li><a href="#method.contains_unknown_bits" title="contains_unknown_bits">contains_unknown_bits</a></li><li><a href="#method.difference" title="difference">difference</a></li><li><a href="#method.empty" title="empty">empty</a></li><li><a href="#method.from_bits" title="from_bits">from_bits</a></li><li><a href="#method.from_bits_truncate" title="from_bits_truncate">from_bits_truncate</a></li><li><a href="#method.from_name" title="from_name">from_name</a></li><li><a href="#method.insert" title="insert">insert</a></li><li><a href="#method.intersection" title="intersection">intersection</a></li><li><a href="#method.intersects" title="intersects">intersects</a></li><li><a href="#method.is_all" title="is_all">is_all</a></li><li><a href="#method.is_empty" title="is_empty">is_empty</a></li><li><a href="#method.iter" title="iter">iter</a></li><li><a href="#method.iter_defined_names" title="iter_defined_names">iter_defined_names</a></li><li><a href="#method.iter_names" title="iter_names">iter_names</a></li><li><a href="#method.known_bits" title="known_bits">known_bits</a></li><li><a href="#method.remove" title="remove">remove</a></li><li><a href="#method.set" title="set">set</a></li><li><a href="#method.symmetric_difference" title="symmetric_difference">symmetric_difference</a></li><li><a href="#method.toggle" title="toggle">toggle</a></li><li><a href="#method.truncate" title="truncate">truncate</a></li><li><a href="#method.union" title="union">union</a></li><li><a href="#method.unknown_bits" title="unknown_bits">unknown_bits</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate bitflags</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">bitflags</a></div><h1>Trait <span class="trait">Flags</span> <button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/bitflags/traits.rs.html#132-351">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Flags: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'static {
|
||
type <a href="#associatedtype.Bits" class="associatedtype">Bits</a>: <a class="trait" href="trait.Bits.html" title="trait bitflags::Bits">Bits</a>;
|
||
|
||
const <a href="#associatedconstant.FLAGS" class="constant">FLAGS</a>: &'static [<a class="struct" href="struct.Flag.html" title="struct bitflags::Flag">Flag</a><Self>];
|
||
<details class="toggle type-contents-toggle"><summary class="hideme"><span>Show 28 methods</span></summary>
|
||
// Required methods
|
||
fn <a href="#tymethod.bits" class="fn">bits</a>(&self) -> Self::<a class="associatedtype" href="trait.Flags.html#associatedtype.Bits" title="type bitflags::Flags::Bits">Bits</a>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.from_bits_retain" class="fn">from_bits_retain</a>(bits: Self::<a class="associatedtype" href="trait.Flags.html#associatedtype.Bits" title="type bitflags::Flags::Bits">Bits</a>) -> Self;
|
||
|
||
// Provided methods
|
||
fn <a href="#method.empty" class="fn">empty</a>() -> Self { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.all" class="fn">all</a>() -> Self { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.known_bits" class="fn">known_bits</a>(&self) -> Self::<a class="associatedtype" href="trait.Flags.html#associatedtype.Bits" title="type bitflags::Flags::Bits">Bits</a> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.unknown_bits" class="fn">unknown_bits</a>(&self) -> Self::<a class="associatedtype" href="trait.Flags.html#associatedtype.Bits" title="type bitflags::Flags::Bits">Bits</a> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.contains_unknown_bits" class="fn">contains_unknown_bits</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.from_bits" class="fn">from_bits</a>(bits: Self::<a class="associatedtype" href="trait.Flags.html#associatedtype.Bits" title="type bitflags::Flags::Bits">Bits</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.from_bits_truncate" class="fn">from_bits_truncate</a>(bits: Self::<a class="associatedtype" href="trait.Flags.html#associatedtype.Bits" title="type bitflags::Flags::Bits">Bits</a>) -> Self { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.from_name" class="fn">from_name</a>(name: &<a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.iter" class="fn">iter</a>(&self) -> <a class="struct" href="iter/struct.Iter.html" title="struct bitflags::iter::Iter">Iter</a><Self> <a href="#" class="tooltip" data-notable-ty="Iter<Self>">ⓘ</a> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.iter_names" class="fn">iter_names</a>(&self) -> <a class="struct" href="iter/struct.IterNames.html" title="struct bitflags::iter::IterNames">IterNames</a><Self> <a href="#" class="tooltip" data-notable-ty="IterNames<Self>">ⓘ</a> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.iter_defined_names" class="fn">iter_defined_names</a>() -> <a class="struct" href="iter/struct.IterDefinedNames.html" title="struct bitflags::iter::IterDefinedNames">IterDefinedNames</a><Self> <a href="#" class="tooltip" data-notable-ty="IterDefinedNames<Self>">ⓘ</a> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.is_empty" class="fn">is_empty</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.is_all" class="fn">is_all</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.intersects" class="fn">intersects</a>(&self, other: Self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a>
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.contains" class="fn">contains</a>(&self, other: Self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a>
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.truncate" class="fn">truncate</a>(&mut self)
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.insert" class="fn">insert</a>(&mut self, other: Self)
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.remove" class="fn">remove</a>(&mut self, other: Self)
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.toggle" class="fn">toggle</a>(&mut self, other: Self)
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.set" class="fn">set</a>(&mut self, other: Self, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a>)
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.clear" class="fn">clear</a>(&mut self)
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.intersection" class="fn">intersection</a>(self, other: Self) -> Self { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.union" class="fn">union</a>(self, other: Self) -> Self { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.difference" class="fn">difference</a>(self, other: Self) -> Self { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.symmetric_difference" class="fn">symmetric_difference</a>(self, other: Self) -> Self { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.complement" class="fn">complement</a>(self) -> Self { ... }
|
||
</details>}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A set of defined flags using a bits type as storage.</p>
|
||
<h3 id="implementing-flags"><a class="doc-anchor" href="#implementing-flags">§</a>Implementing <code>Flags</code></h3>
|
||
<p>This trait is implemented by the <a href="macro.bitflags.html"><code>bitflags</code></a> macro:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bitflags::bitflags;
|
||
|
||
<span class="macro">bitflags!</span> {
|
||
<span class="kw">struct </span>MyFlags: u8 {
|
||
<span class="kw">const </span>A = <span class="number">1</span>;
|
||
<span class="kw">const </span>B = <span class="number">1 </span><< <span class="number">1</span>;
|
||
}
|
||
}</code></pre></div>
|
||
<p>It can also be implemented manually:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bitflags::{Flag, Flags};
|
||
|
||
<span class="kw">struct </span>MyFlags(u8);
|
||
|
||
<span class="kw">impl </span>Flags <span class="kw">for </span>MyFlags {
|
||
<span class="kw">const </span>FLAGS: <span class="kw-2">&</span><span class="lifetime">'static </span>[Flag<<span class="self">Self</span>>] = <span class="kw-2">&</span>[
|
||
Flag::new(<span class="string">"A"</span>, MyFlags(<span class="number">1</span>)),
|
||
Flag::new(<span class="string">"B"</span>, MyFlags(<span class="number">1 </span><< <span class="number">1</span>)),
|
||
];
|
||
|
||
<span class="kw">type </span>Bits = u8;
|
||
|
||
<span class="kw">fn </span>from_bits_retain(bits: <span class="self">Self</span>::Bits) -> <span class="self">Self </span>{
|
||
MyFlags(bits)
|
||
}
|
||
|
||
<span class="kw">fn </span>bits(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="self">Self</span>::Bits {
|
||
<span class="self">self</span>.<span class="number">0
|
||
</span>}
|
||
}</code></pre></div><h3 id="using-flags"><a class="doc-anchor" href="#using-flags">§</a>Using <code>Flags</code></h3>
|
||
<p>The <code>Flags</code> trait can be used generically to work with any flags types. In this example,
|
||
we can count the number of defined named flags:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">fn </span>defined_flags<F: Flags>() -> usize {
|
||
F::FLAGS.iter().filter(|f| f.is_named()).count()
|
||
}
|
||
|
||
<span class="macro">bitflags!</span> {
|
||
<span class="kw">struct </span>MyFlags: u8 {
|
||
<span class="kw">const </span>A = <span class="number">1</span>;
|
||
<span class="kw">const </span>B = <span class="number">1 </span><< <span class="number">1</span>;
|
||
<span class="kw">const </span>C = <span class="number">1 </span><< <span class="number">2</span>;
|
||
|
||
<span class="kw">const _ </span>= !<span class="number">0</span>;
|
||
}
|
||
}
|
||
|
||
<span class="macro">assert_eq!</span>(<span class="number">3</span>, defined_flags::<MyFlags>());</code></pre></div></div></details><h2 id="required-associated-consts" class="section-header">Required Associated Constants<a href="#required-associated-consts" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedconstant.FLAGS" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#134">Source</a><h4 class="code-header">const <a href="#associatedconstant.FLAGS" class="constant">FLAGS</a>: &'static [<a class="struct" href="struct.Flag.html" title="struct bitflags::Flag">Flag</a><Self>]</h4></section></summary><div class="docblock"><p>The set of defined flags.</p>
|
||
</div></details></div><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Bits" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#137">Source</a><h4 class="code-header">type <a href="#associatedtype.Bits" class="associatedtype">Bits</a>: <a class="trait" href="trait.Bits.html" title="trait bitflags::Bits">Bits</a></h4></section></summary><div class="docblock"><p>The underlying bits type.</p>
|
||
</div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.bits" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#173">Source</a><h4 class="code-header">fn <a href="#tymethod.bits" class="fn">bits</a>(&self) -> Self::<a class="associatedtype" href="trait.Flags.html#associatedtype.Bits" title="type bitflags::Flags::Bits">Bits</a></h4></section></summary><div class="docblock"><p>Get the underlying bits value.</p>
|
||
<p>The returned value is exactly the bits set in this flags value.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.from_bits_retain" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#194">Source</a><h4 class="code-header">fn <a href="#tymethod.from_bits_retain" class="fn">from_bits_retain</a>(bits: Self::<a class="associatedtype" href="trait.Flags.html#associatedtype.Bits" title="type bitflags::Flags::Bits">Bits</a>) -> Self</h4></section></summary><div class="docblock"><p>Convert from a bits value exactly.</p>
|
||
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.empty" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#140-142">Source</a><h4 class="code-header">fn <a href="#method.empty" class="fn">empty</a>() -> Self</h4></section></summary><div class="docblock"><p>Get a flags value with all bits unset.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.all" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#145-153">Source</a><h4 class="code-header">fn <a href="#method.all" class="fn">all</a>() -> Self</h4></section></summary><div class="docblock"><p>Get a flags value with all known bits set.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.known_bits" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#156-158">Source</a><h4 class="code-header">fn <a href="#method.known_bits" class="fn">known_bits</a>(&self) -> Self::<a class="associatedtype" href="trait.Flags.html#associatedtype.Bits" title="type bitflags::Flags::Bits">Bits</a></h4></section></summary><div class="docblock"><p>Get the known bits from a flags value.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.unknown_bits" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#161-163">Source</a><h4 class="code-header">fn <a href="#method.unknown_bits" class="fn">unknown_bits</a>(&self) -> Self::<a class="associatedtype" href="trait.Flags.html#associatedtype.Bits" title="type bitflags::Flags::Bits">Bits</a></h4></section></summary><div class="docblock"><p>Get the unknown bits from a flags value.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.contains_unknown_bits" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#166-168">Source</a><h4 class="code-header">fn <a href="#method.contains_unknown_bits" class="fn">contains_unknown_bits</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>This method will return <code>true</code> if any unknown bits are set.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_bits" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#178-186">Source</a><h4 class="code-header">fn <a href="#method.from_bits" class="fn">from_bits</a>(bits: Self::<a class="associatedtype" href="trait.Flags.html#associatedtype.Bits" title="type bitflags::Flags::Bits">Bits</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self></h4></section></summary><div class="docblock"><p>Convert from a bits value.</p>
|
||
<p>This method will return <code>None</code> if any unknown bits are set.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_bits_truncate" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#189-191">Source</a><h4 class="code-header">fn <a href="#method.from_bits_truncate" class="fn">from_bits_truncate</a>(bits: Self::<a class="associatedtype" href="trait.Flags.html#associatedtype.Bits" title="type bitflags::Flags::Bits">Bits</a>) -> Self</h4></section></summary><div class="docblock"><p>Convert from a bits value, unsetting any unknown bits.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_name" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#200-213">Source</a><h4 class="code-header">fn <a href="#method.from_name" class="fn">from_name</a>(name: &<a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self></h4></section></summary><div class="docblock"><p>Get a flags value with the bits of a flag with the given name set.</p>
|
||
<p>This method will return <code>None</code> if <code>name</code> is empty or doesn’t
|
||
correspond to any named flag.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#219-221">Source</a><h4 class="code-header">fn <a href="#method.iter" class="fn">iter</a>(&self) -> <a class="struct" href="iter/struct.Iter.html" title="struct bitflags::iter::Iter">Iter</a><Self> <a href="#" class="tooltip" data-notable-ty="Iter<Self>">ⓘ</a></h4></section></summary><div class="docblock"><p>Yield a set of contained flags values.</p>
|
||
<p>Each yielded flags value will correspond to a defined named flag. Any unknown bits
|
||
will be yielded together as a final flags value.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter_names" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#227-229">Source</a><h4 class="code-header">fn <a href="#method.iter_names" class="fn">iter_names</a>(&self) -> <a class="struct" href="iter/struct.IterNames.html" title="struct bitflags::iter::IterNames">IterNames</a><Self> <a href="#" class="tooltip" data-notable-ty="IterNames<Self>">ⓘ</a></h4></section></summary><div class="docblock"><p>Yield a set of contained named flags values.</p>
|
||
<p>This method is like <a href="trait.Flags.html#method.iter" title="method bitflags::Flags::iter"><code>Flags::iter</code></a>, except only yields bits in contained named flags.
|
||
Any unknown bits, or bits not corresponding to a contained flag will not be yielded.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter_defined_names" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#232-234">Source</a><h4 class="code-header">fn <a href="#method.iter_defined_names" class="fn">iter_defined_names</a>() -> <a class="struct" href="iter/struct.IterDefinedNames.html" title="struct bitflags::iter::IterDefinedNames">IterDefinedNames</a><Self> <a href="#" class="tooltip" data-notable-ty="IterDefinedNames<Self>">ⓘ</a></h4></section></summary><div class="docblock"><p>Yield a set of all named flags defined by <a href="trait.Flags.html#associatedconstant.FLAGS"><code>Self::FLAGS</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_empty" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#237-239">Source</a><h4 class="code-header">fn <a href="#method.is_empty" class="fn">is_empty</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Whether all bits in this flags value are unset.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_all" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#242-246">Source</a><h4 class="code-header">fn <a href="#method.is_all" class="fn">is_all</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Whether all known bits in this flags value are set.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.intersects" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#249-254">Source</a><h4 class="code-header">fn <a href="#method.intersects" class="fn">intersects</a>(&self, other: Self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a><div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Whether any set bits in a source flags value are also set in a target flags value.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.contains" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#257-262">Source</a><h4 class="code-header">fn <a href="#method.contains" class="fn">contains</a>(&self, other: Self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a><div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Whether all set bits in a source flags value are also set in a target flags value.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.truncate" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#265-270">Source</a><h4 class="code-header">fn <a href="#method.truncate" class="fn">truncate</a>(&mut self)<div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Remove any unknown bits from the flags.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.insert" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#273-278">Source</a><h4 class="code-header">fn <a href="#method.insert" class="fn">insert</a>(&mut self, other: Self)<div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>The bitwise or (<code>|</code>) of the bits in two flags values.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.remove" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#284-289">Source</a><h4 class="code-header">fn <a href="#method.remove" class="fn">remove</a>(&mut self, other: Self)<div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>The intersection of a source flags value with the complement of a target flags value (<code>&!</code>).</p>
|
||
<p>This method is not equivalent to <code>self & !other</code> when <code>other</code> has unknown bits set.
|
||
<code>remove</code> won’t truncate <code>other</code>, but the <code>!</code> operator will.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.toggle" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#292-297">Source</a><h4 class="code-header">fn <a href="#method.toggle" class="fn">toggle</a>(&mut self, other: Self)<div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>The bitwise exclusive-or (<code>^</code>) of the bits in two flags values.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#300-309">Source</a><h4 class="code-header">fn <a href="#method.set" class="fn">set</a>(&mut self, other: Self, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.bool.html">bool</a>)<div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Call <a href="trait.Flags.html#method.insert" title="method bitflags::Flags::insert"><code>Flags::insert</code></a> when <code>value</code> is <code>true</code> or <a href="trait.Flags.html#method.remove" title="method bitflags::Flags::remove"><code>Flags::remove</code></a> when <code>value</code> is <code>false</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.clear" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#312-317">Source</a><h4 class="code-header">fn <a href="#method.clear" class="fn">clear</a>(&mut self)<div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Unsets all bits in the flags.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.intersection" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#321-323">Source</a><h4 class="code-header">fn <a href="#method.intersection" class="fn">intersection</a>(self, other: Self) -> Self</h4></section></summary><div class="docblock"><p>The bitwise and (<code>&</code>) of the bits in two flags values.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.union" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#327-329">Source</a><h4 class="code-header">fn <a href="#method.union" class="fn">union</a>(self, other: Self) -> Self</h4></section></summary><div class="docblock"><p>The bitwise or (<code>|</code>) of the bits in two flags values.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.difference" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#336-338">Source</a><h4 class="code-header">fn <a href="#method.difference" class="fn">difference</a>(self, other: Self) -> Self</h4></section></summary><div class="docblock"><p>The intersection of a source flags value with the complement of a target flags value (<code>&!</code>).</p>
|
||
<p>This method is not equivalent to <code>self & !other</code> when <code>other</code> has unknown bits set.
|
||
<code>difference</code> won’t truncate <code>other</code>, but the <code>!</code> operator will.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.symmetric_difference" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#342-344">Source</a><h4 class="code-header">fn <a href="#method.symmetric_difference" class="fn">symmetric_difference</a>(self, other: Self) -> Self</h4></section></summary><div class="docblock"><p>The bitwise exclusive-or (<code>^</code>) of the bits in two flags values.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.complement" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#348-350">Source</a><h4 class="code-header">fn <a href="#method.complement" class="fn">complement</a>(self) -> Self</h4></section></summary><div class="docblock"><p>The bitwise negation (<code>!</code>) of the bits in a flags value, truncating the result.</p>
|
||
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../trait.impl/bitflags/traits/trait.Flags.js" async></script><script type="text/json" id="notable-traits-data">{"Iter<Self>":"<h3>Notable traits for <code><a class=\"struct\" href=\"iter/struct.Iter.html\" title=\"struct bitflags::iter::Iter\">Iter</a><B></code></h3><pre><code><div class=\"where\">impl<B: <a class=\"trait\" href=\"trait.Flags.html\" title=\"trait bitflags::Flags\">Flags</a>> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"iter/struct.Iter.html\" title=\"struct bitflags::iter::Iter\">Iter</a><B></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = B;</div>","IterDefinedNames<Self>":"<h3>Notable traits for <code><a class=\"struct\" href=\"iter/struct.IterDefinedNames.html\" title=\"struct bitflags::iter::IterDefinedNames\">IterDefinedNames</a><B></code></h3><pre><code><div class=\"where\">impl<B: <a class=\"trait\" href=\"trait.Flags.html\" title=\"trait bitflags::Flags\">Flags</a>> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"iter/struct.IterDefinedNames.html\" title=\"struct bitflags::iter::IterDefinedNames\">IterDefinedNames</a><B></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = (&'static <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.93.1/core/primitive.str.html\">str</a>, B);</div>","IterNames<Self>":"<h3>Notable traits for <code><a class=\"struct\" href=\"iter/struct.IterNames.html\" title=\"struct bitflags::iter::IterNames\">IterNames</a><B></code></h3><pre><code><div class=\"where\">impl<B: <a class=\"trait\" href=\"trait.Flags.html\" title=\"trait bitflags::Flags\">Flags</a>> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"iter/struct.IterNames.html\" title=\"struct bitflags::iter::IterNames\">IterNames</a><B></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = (&'static <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.93.1/core/primitive.str.html\">str</a>, B);</div>"}</script></section></div></main></body></html> |