pub fn try_from_slice_mut(
		slice: &mut [T],
	) -> Result<&mut Self, BitSpanError<T>> {
		let elts = slice.len();
		if elts >= Self::MAX_ELTS {
			elts.saturating_mul(mem::bits_of::<T::Mem>())
				.pipe(BitSpanError::TooLong)
				.pipe(Err)
		}
		else {
			Ok(unsafe { Self::from_slice_unchecked_mut(slice) })
		}
	}
/// Attempts to construct an exclusive `&mut BitSlice` reference over a
/// slice of elements.
///
/// The [`BitView`] trait, implemented on all `[T]` slices, provides a
/// [`.try_view_bits_mut::<O>()`] method which delegates to this function
/// and may be more convenient for you to write.
///
/// ## Parameters
///
/// - `slice`: An exclusive reference to a slice of memory elements.
///
/// ## Returns
///
/// An exclusive `&mut BitSlice` over `slice`. If `slice` is longer than can
/// be encoded into a `&mut BitSlice` (see [`MAX_ELTS`]), this will fail and
/// return the original `slice` as an error.
///
/// ## Examples
///
/// ```rust
/// use bitvec::prelude::*;
///
/// let mut data = [0u8; 2];
/// let bits = BitSlice::<_, Msb0>::try_from_slice_mut(&mut data).unwrap();
/// bits.set(7, true);
/// bits.set(15, true);
/// assert_eq!(data, [1; 2]);
///
/// let bits = data.try_view_bits_mut::<Msb0>().unwrap();
/// ```
///
/// [`BitView`]: crate::view::BitView
/// [`MAX_ELTS`]: Self::MAX_ELTS
/// [`.try_view_bits_mut::<O>()`]: crate::view::BitView::try_view_bits_mut
Attempts to construct an exclusive `&mut BitSlice` reference over a
slice of elements.


Attempts to construct an exclusive ` &mut BitSlice ` reference over a slice of elements .
pub fn try_from_slice_mut(
		slice: &mut [T],
	) -> Result<&mut Self, BitSpanError<T>> {
		let elts = slice.len();
		if elts >= Self::MAX_ELTS {
			elts.saturating_mul(mem::bits_of::<T::Mem>())
				.pipe(BitSpanError::TooLong)
				.pipe(Err)
		}
		else {
			Ok(unsafe { Self::from_slice_unchecked_mut(slice) })
		}
	}
pub fn try_from_slice_mut ( slice : & mut [ T ] , ) -> Result < & mut Self , BitSpanError < T > > { let elts = slice . len ( ) ; if elts >= Self :: MAX_ELTS { elts . saturating_mul ( mem :: bits_of :: < T :: Mem > ( ) ) . pipe ( BitSpanError :: TooLong ) . pipe ( Err ) } else { Ok ( unsafe { Self :: from_slice_unchecked_mut ( slice ) } ) } }
Attempts to construct an exclusive `&mut BitSlice` reference over a
slice of elements.
Attempts to construct an exclusive ` &mut BitSlice ` reference over a slice of elements .
slice
&mut [T]
An exclusive `&mut BitSlice` over `slice`. If `slice` is longer than can
be encoded into a `&mut BitSlice` , this will fail and
return the original `slice` as an error.
An exclusive ` &mut BitSlice ` over ` slice ` . If ` slice ` is longer than can be encoded into a ` &mut BitSlice ` this will fail and return the original ` slice ` as an error .
slice
&mut [T]
An exclusive reference to a slice of memory elements.
An exclusive reference to a slice of memory elements .
examples
```rust
use bitvec::prelude::*.



let bits = data.try_view_bits_mut::().unwrap();
```


` ` ` rust use bitvec :: prelude :: * . let bits = data . try_view_bits_mut :: () . unwrap () ; ` ` `