[−][src]Struct bitvec::slice::BitMut
Proxy reference type, equivalent to &mut bool.
This is a two-word structure capable of correctly referring to a single bit in
a memory element. Because Rust does not permit reference-like objects in the
same manner that C++ does – &T and &mut T values are required to be
immediately-valid pointers, not objects – bitvec cannot manifest encoded
&mut Bit values in the same way that it can manifest &mut BitSlice.
Instead, this type implements Deref and DerefMut to an internal bool slot,
and in Drop commits the value of that bool to the proxied bit in the source
BitSlice from which the BitMut value was created. The combination of Rust’s
own exclusion rules and the aliasing type system in this library ensure that a
BitMut value has unique access to the bit it proxies, and the memory element
it uses will not have destructive data races from other views.
Lifetimes
'a: The lifetime of the source&'a mut BitSlicethat created theBitMut.
Type Parameters
O: TheBitOrdertype parameter from the source&mut BitSlice.T: TheBitStoretype parameter from the source&mut BitSlice.
Examples
use bitvec::prelude::*; let bits = bits![mut 0; 2]; let (left, right) = bits.split_at_mut(1); let mut first = left.get_mut(0).unwrap(); let second = right.get_mut(0).unwrap(); // Referential behavior *first = true; // Direct write second.set(true); drop(first); // it’s not a reference! assert_eq!(bits, bits![1; 2]);
Implementations
impl<O, T, '_> BitMut<'_, O, T> where
O: BitOrder,
T: BitStore, [src]
O: BitOrder,
T: BitStore,
pub fn set(self, value: bool)[src]
Writes a bit into the proxied location without an intermediate copy.
This function writes value directly into the proxied location, and
does not store value in the proxy’s internal cache. This should be
equivalent to the behavior seen when using ordinary DerefMut proxying,
but the latter depends on compiler optimization.
Parameters
self: This destroys the proxy, as it becomes invalid when writing directly to the location without updating the cache.value: The new bit to write into the proxied slot.
Trait Implementations
impl<O, T, '_> Debug for BitMut<'_, O, T> where
O: BitOrder,
T: BitStore, [src]
O: BitOrder,
T: BitStore,
impl<O, T, '_> Deref for BitMut<'_, O, T> where
O: BitOrder,
T: BitStore, [src]
O: BitOrder,
T: BitStore,
impl<O, T, '_> DerefMut for BitMut<'_, O, T> where
O: BitOrder,
T: BitStore, [src]
O: BitOrder,
T: BitStore,
impl<O, T, '_> Drop for BitMut<'_, O, T> where
O: BitOrder,
T: BitStore, [src]
O: BitOrder,
T: BitStore,
Auto Trait Implementations
impl<'a, O, T> RefUnwindSafe for BitMut<'a, O, T> where
O: RefUnwindSafe,
T: RefUnwindSafe,
<T as BitStore>::Access: RefUnwindSafe,
<T as BitStore>::Mem: RefUnwindSafe,
O: RefUnwindSafe,
T: RefUnwindSafe,
<T as BitStore>::Access: RefUnwindSafe,
<T as BitStore>::Mem: RefUnwindSafe,
impl<'a, O, T> !Send for BitMut<'a, O, T>
impl<'a, O, T> !Sync for BitMut<'a, O, T>
impl<'a, O, T> Unpin for BitMut<'a, O, T> where
<T as BitStore>::Mem: Unpin,
<T as BitStore>::Mem: Unpin,
impl<'a, O, T> !UnwindSafe for BitMut<'a, O, T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Conv for T[src]
impl<T> FmtForward for T[src]
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary, [src]
Self: Binary,
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display, [src]
Self: Display,
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp, [src]
Self: LowerExp,
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex, [src]
Self: LowerHex,
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal, [src]
Self: Octal,
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer, [src]
Self: Pointer,
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp, [src]
Self: UpperExp,
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex, [src]
Self: UpperHex,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Pipe for T[src]
impl<T> PipeAsRef for T[src]
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
R: 'a,
Self: AsRef<T>,
T: 'a, [src]
R: 'a,
Self: AsRef<T>,
T: 'a,
fn pipe_as_mut<'a, T, R>(&'a mut self, func: impl FnOnce(&'a mut T) -> R) -> R where
R: 'a,
Self: AsMut<T>,
T: 'a, [src]
R: 'a,
Self: AsMut<T>,
T: 'a,
impl<T> PipeBorrow for T[src]
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
R: 'a,
Self: Borrow<T>,
T: 'a, [src]
R: 'a,
Self: Borrow<T>,
T: 'a,
fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
R: 'a,
Self: BorrowMut<T>,
T: 'a, [src]
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
R: 'a,
Self: BorrowMut<T>,
T: 'a,
impl<T> PipeDeref for T[src]
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
R: 'a,
Self: Deref, [src]
R: 'a,
Self: Deref,
fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
R: 'a,
Self: DerefMut, [src]
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
R: 'a,
Self: DerefMut,
impl<T> PipeRef for T[src]
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a, [src]
R: 'a,
fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a, [src]
R: 'a,
impl<T> Tap for T[src]
fn tap<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R, [src]
F: FnOnce(&Self) -> R,
fn tap_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R, [src]
F: FnOnce(&Self) -> R,
fn tap_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R, [src]
F: FnOnce(&mut Self) -> R,
fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R, [src]
F: FnOnce(&mut Self) -> R,
impl<T, U> TapAsRef<U> for T where
U: ?Sized, [src]
U: ?Sized,
fn tap_ref<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: AsRef<T>, [src]
F: FnOnce(&T) -> R,
Self: AsRef<T>,
fn tap_ref_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: AsRef<T>, [src]
F: FnOnce(&T) -> R,
Self: AsRef<T>,
fn tap_ref_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: AsMut<T>, [src]
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: AsMut<T>, [src]
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
impl<T, U> TapBorrow<U> for T where
U: ?Sized, [src]
U: ?Sized,
fn tap_borrow<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: Borrow<T>, [src]
F: FnOnce(&T) -> R,
Self: Borrow<T>,
fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: Borrow<T>, [src]
F: FnOnce(&T) -> R,
Self: Borrow<T>,
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>, [src]
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>, [src]
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
impl<T> TapDeref for T[src]
fn tap_deref<F, R>(self, func: F) -> Self where
F: FnOnce(&Self::Target) -> R,
Self: Deref, [src]
F: FnOnce(&Self::Target) -> R,
Self: Deref,
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self::Target) -> R,
Self: Deref, [src]
F: FnOnce(&Self::Target) -> R,
Self: Deref,
fn tap_deref_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut, [src]
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut, [src]
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
impl<T> TryConv for T[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,