edlang/bitflags/trait.Flags.html
2024-07-26 09:42:18 +00:00

132 lines
30 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-dd39b87e5fcfba68.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.80.0 (051478957 2024-07-21)" data-channel="1.80.0" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.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]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../bitflags/index.html">bitflags</a><span class="version">2.6.0</span></h2></div><h2 class="location"><a href="#">Flags</a></h2><div class="sidebar-elems"><section><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Bits">Bits</a></li></ul><h3><a href="#required-associated-consts">Required Associated Constants</a></h3><ul class="block"><li><a href="#associatedconstant.FLAGS">FLAGS</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.bits">bits</a></li><li><a href="#tymethod.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">all</a></li><li><a href="#method.complement">complement</a></li><li><a href="#method.contains">contains</a></li><li><a href="#method.difference">difference</a></li><li><a href="#method.empty">empty</a></li><li><a href="#method.from_bits">from_bits</a></li><li><a href="#method.from_bits_truncate">from_bits_truncate</a></li><li><a href="#method.from_name">from_name</a></li><li><a href="#method.insert">insert</a></li><li><a href="#method.intersection">intersection</a></li><li><a href="#method.intersects">intersects</a></li><li><a href="#method.is_all">is_all</a></li><li><a href="#method.is_empty">is_empty</a></li><li><a href="#method.iter">iter</a></li><li><a href="#method.iter_names">iter_names</a></li><li><a href="#method.remove">remove</a></li><li><a href="#method.set">set</a></li><li><a href="#method.symmetric_difference">symmetric_difference</a></li><li><a href="#method.toggle">toggle</a></li><li><a href="#method.union">union</a></li></ul><h3><a href="#object-safety">Object Safety</a></h3><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In crate bitflags</a></h2></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Trait <a href="index.html">bitflags</a>::<wbr><a class="trait" href="#">Flags</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../src/bitflags/traits.rs.html#132-315">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub trait Flags: <a class="trait" href="https://doc.rust-lang.org/1.80.0/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>: &amp;'static [<a class="struct" href="struct.Flag.html" title="struct bitflags::Flag">Flag</a>&lt;Self&gt;];
<details class="toggle type-contents-toggle"><summary class="hideme"><span>Show 22 methods</span></summary>
// Required methods
fn <a href="#tymethod.bits" class="fn">bits</a>(&amp;self) -&gt; 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>) -&gt; Self;
// Provided methods
fn <a href="#method.empty" class="fn">empty</a>() -&gt; Self { ... }
<span class="item-spacer"></span> fn <a href="#method.all" class="fn">all</a>() -&gt; Self { ... }
<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>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Self&gt; { ... }
<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>) -&gt; Self { ... }
<span class="item-spacer"></span> fn <a href="#method.from_name" class="fn">from_name</a>(name: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/core/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Self&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.iter" class="fn">iter</a>(&amp;self) -&gt; <a class="struct" href="iter/struct.Iter.html" title="struct bitflags::iter::Iter">Iter</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="Iter&lt;Self&gt;"></a> { ... }
<span class="item-spacer"></span> fn <a href="#method.iter_names" class="fn">iter_names</a>(&amp;self) -&gt; <a class="struct" href="iter/struct.IterNames.html" title="struct bitflags::iter::IterNames">IterNames</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="IterNames&lt;Self&gt;"></a> { ... }
<span class="item-spacer"></span> fn <a href="#method.is_empty" class="fn">is_empty</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/core/primitive.bool.html">bool</a> { ... }
<span class="item-spacer"></span> fn <a href="#method.is_all" class="fn">is_all</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/core/primitive.bool.html">bool</a> { ... }
<span class="item-spacer"></span> fn <a href="#method.intersects" class="fn">intersects</a>(&amp;self, other: Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/core/primitive.bool.html">bool</a>
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/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>(&amp;self, other: Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/core/primitive.bool.html">bool</a>
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/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>(&amp;mut self, other: Self)
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/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>(&amp;mut self, other: Self)
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/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>(&amp;mut self, other: Self)
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/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>(&amp;mut self, other: Self, value: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/core/primitive.bool.html">bool</a>)
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/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) -&gt; Self { ... }
<span class="item-spacer"></span> fn <a href="#method.union" class="fn">union</a>(self, other: Self) -&gt; Self { ... }
<span class="item-spacer"></span> fn <a href="#method.difference" class="fn">difference</a>(self, other: Self) -&gt; Self { ... }
<span class="item-spacer"></span> fn <a href="#method.symmetric_difference" class="fn">symmetric_difference</a>(self, other: Self) -&gt; Self { ... }
<span class="item-spacer"></span> fn <a href="#method.complement" class="fn">complement</a>(self) -&gt; 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>&lt;&lt; <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">&amp;</span><span class="lifetime">'static </span>[Flag&lt;<span class="self">Self</span>&gt;] = <span class="kw-2">&amp;</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>&lt;&lt; <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) -&gt; <span class="self">Self </span>{
MyFlags(bits)
}
<span class="kw">fn </span>bits(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <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&lt;F: Flags&gt;() -&gt; 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>&lt;&lt; <span class="number">1</span>;
<span class="kw">const </span>C = <span class="number">1 </span>&lt;&lt; <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::&lt;MyFlags&gt;());</code></pre></div>
</div></details><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-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>: &amp;'static [<a class="struct" href="struct.Flag.html" title="struct bitflags::Flag">Flag</a>&lt;Self&gt;]</h4></section></summary><div class="docblock"><p>The set of defined flags.</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#158">source</a><h4 class="code-header">fn <a href="#tymethod.bits" class="fn">bits</a>(&amp;self) -&gt; 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#179">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>) -&gt; 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>() -&gt; 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>() -&gt; 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.from_bits" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#163-171">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>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Self&gt;</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#174-176">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>) -&gt; 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#185-198">source</a><h4 class="code-header">fn <a href="#method.from_name" class="fn">from_name</a>(name: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/core/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Self&gt;</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 doesnt
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#204-206">source</a><h4 class="code-header">fn <a href="#method.iter" class="fn">iter</a>(&amp;self) -&gt; <a class="struct" href="iter/struct.Iter.html" title="struct bitflags::iter::Iter">Iter</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="Iter&lt;Self&gt;"></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#212-214">source</a><h4 class="code-header">fn <a href="#method.iter_names" class="fn">iter_names</a>(&amp;self) -&gt; <a class="struct" href="iter/struct.IterNames.html" title="struct bitflags::iter::IterNames">IterNames</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="IterNames&lt;Self&gt;"></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.is_empty" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#217-219">source</a><h4 class="code-header">fn <a href="#method.is_empty" class="fn">is_empty</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/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#222-226">source</a><h4 class="code-header">fn <a href="#method.is_all" class="fn">is_all</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/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#229-234">source</a><h4 class="code-header">fn <a href="#method.intersects" class="fn">intersects</a>(&amp;self, other: Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/core/primitive.bool.html">bool</a><div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/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#237-242">source</a><h4 class="code-header">fn <a href="#method.contains" class="fn">contains</a>(&amp;self, other: Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/core/primitive.bool.html">bool</a><div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/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.insert" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#245-250">source</a><h4 class="code-header">fn <a href="#method.insert" class="fn">insert</a>(&amp;mut self, other: Self)<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/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#256-261">source</a><h4 class="code-header">fn <a href="#method.remove" class="fn">remove</a>(&amp;mut self, other: Self)<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/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>&amp;!</code>).</p>
<p>This method is not equivalent to <code>self &amp; !other</code> when <code>other</code> has unknown bits set.
<code>remove</code> wont 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#264-269">source</a><h4 class="code-header">fn <a href="#method.toggle" class="fn">toggle</a>(&amp;mut self, other: Self)<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/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#272-281">source</a><h4 class="code-header">fn <a href="#method.set" class="fn">set</a>(&amp;mut self, other: Self, value: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/core/primitive.bool.html">bool</a>)<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/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.intersection" class="method"><a class="src rightside" href="../src/bitflags/traits.rs.html#285-287">source</a><h4 class="code-header">fn <a href="#method.intersection" class="fn">intersection</a>(self, other: Self) -&gt; Self</h4></section></summary><div class="docblock"><p>The bitwise and (<code>&amp;</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#291-293">source</a><h4 class="code-header">fn <a href="#method.union" class="fn">union</a>(self, other: Self) -&gt; 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#300-302">source</a><h4 class="code-header">fn <a href="#method.difference" class="fn">difference</a>(self, other: Self) -&gt; Self</h4></section></summary><div class="docblock"><p>The intersection of a source flags value with the complement of a target flags value (<code>&amp;!</code>).</p>
<p>This method is not equivalent to <code>self &amp; !other</code> when <code>other</code> has unknown bits set.
<code>difference</code> wont 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#306-308">source</a><h4 class="code-header">fn <a href="#method.symmetric_difference" class="fn">symmetric_difference</a>(self, other: Self) -&gt; 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#312-314">source</a><h4 class="code-header">fn <a href="#method.complement" class="fn">complement</a>(self) -&gt; 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="object-safety" class="section-header">Object Safety<a href="#object-safety" class="anchor">§</a></h2><div class="object-safety-info">This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.80.0/reference/items/traits.html#object-safety">object safe</a>.</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>&lt;B&gt;</code></h3><pre><code><div class=\"where\">impl&lt;B: <a class=\"trait\" href=\"trait.Flags.html\" title=\"trait bitflags::Flags\">Flags</a>&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.80.0/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>&lt;B&gt;</div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.80.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</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>&lt;B&gt;</code></h3><pre><code><div class=\"where\">impl&lt;B: <a class=\"trait\" href=\"trait.Flags.html\" title=\"trait bitflags::Flags\">Flags</a>&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.80.0/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>&lt;B&gt;</div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.80.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = (&amp;'static <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.80.0/core/primitive.str.html\">str</a>, B);</div>"}</script></section></div></main></body></html>