Skip to main content

BitString

Struct BitString 

Source
pub struct BitString { /* private fields */ }

Implementations§

Source§

impl BitString

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn get(&self, index: usize) -> Option<bool>

Source§

impl BitString

Source

pub fn any(&self) -> bool

Source

pub fn all(&self) -> bool

Source

pub fn is_all_zeros(&self) -> bool

Source

pub fn is_all_ones(&self) -> bool

Source§

impl BitString

Source

pub fn as_words(&self) -> &[u64]

Returns the internal little-endian words.

Bit index i is stored in word i / 64, bit offset i % 64. Unused high bits in the last word are guaranteed to be zero.

Source

pub fn first(&self) -> Option<bool>

Source

pub fn get_chunk(&self, bit_start: usize) -> u64

Reads up to 64 bits starting at bit_start, returning them in the low bits of a u64.

Bits beyond self.len() are treated as zero.

Source

pub fn last(&self) -> Option<bool>

Source

pub fn to_bool_vec(&self) -> Vec<bool>

Source§

impl BitString

Source

pub fn and(&self, rhs: &Self) -> Result<Self, BitStringLenMismatch>

Returns self & rhs without mutating either input.

Source

pub fn and_assign(&mut self, rhs: &Self) -> Result<(), BitStringLenMismatch>

Replaces self with self & rhs.

Source

pub fn and_into(self, rhs: &Self) -> Result<Self, BitStringLenMismatch>

Consumes self, reuses its backing storage, and returns self & rhs.

Source§

impl BitString

Source

pub fn or(&self, rhs: &Self) -> Result<Self, BitStringLenMismatch>

Returns self & rhs without mutating either input.

Source

pub fn or_assign(&mut self, rhs: &Self) -> Result<(), BitStringLenMismatch>

Replaces self with self & rhs.

Source

pub fn or_into(self, rhs: &Self) -> Result<Self, BitStringLenMismatch>

Consumes self, reuses its backing storage, and returns self & rhs.

Source§

impl BitString

Source

pub fn xor(&self, rhs: &Self) -> Result<Self, BitStringLenMismatch>

Returns self & rhs without mutating either input.

Source

pub fn xor_assign(&mut self, rhs: &Self) -> Result<(), BitStringLenMismatch>

Replaces self with self & rhs.

Source

pub fn xor_into(self, rhs: &Self) -> Result<Self, BitStringLenMismatch>

Consumes self, reuses its backing stxorage, and returns self & rhs.

Source§

impl BitString

Source

pub fn count_ones(&self) -> usize

Source

pub fn count_zeros(&self) -> usize

Source§

impl BitString

Source

pub fn not(&self) -> Self

Returns !self without mutating the input.

Source

pub fn not_assign(&mut self)

Replaces self with !self.

Source

pub fn not_into(self) -> Self

Consumes self, reuses its backing storage, and returns !self.

Source§

impl BitString

Source

pub fn shl(&self, amount: usize) -> Self

Returns self << amount, filling new bits with zero.

Source

pub fn shl_assign(&mut self, amount: usize)

Replaces self with self << amount, filling new bits with zero.

Source

pub fn shl_into(self, amount: usize) -> Self

Consumes self, reuses its backing storage, and returns self << amount.

Source§

impl BitString

Source

pub fn shr(&self, amount: usize) -> Self

Returns self >> amount, filling new bits with zero.

Source

pub fn shr_assign(&mut self, amount: usize)

Replaces self with self >> amount, filling new bits with zero.

Source

pub fn shr_into(self, amount: usize) -> Self

Consumes self, reuses its backing storage, and returns self >> amount.

Source§

impl BitString

Source

pub fn from_words(words: &[u64], len: usize) -> Option<Self>

Constructs a bit string from packed little-endian words.

The input must contain exactly enough words for len. Unused high bits in the last word are masked out.

Source§

impl BitString

Source

pub fn new() -> Self

Source§

impl BitString

Source

pub fn repeat(value: bool, len: usize) -> Self

Source

pub fn zeros(len: usize) -> Self

Source

pub fn ones(len: usize) -> Self

Source§

impl BitString

Source

pub fn set(&mut self, index: usize, value: bool) -> Option<bool>

Source

pub fn set_chunk(&mut self, bit_start: usize, value: u64, len: usize)

Writes len bits of value starting at bit_start, OR-ing them with the existing bits. Bits beyond self.len() are ignored.

Only the low len bits of value are used; higher bits are masked out.

Source

pub fn push(&mut self, value: bool)

Source

pub fn pop(&mut self) -> Option<bool>

Source

pub fn truncate(&mut self, len: usize)

Source

pub fn clear(&mut self)

Source

pub fn insert(&mut self, index: usize, value: bool)

Source

pub fn remove(&mut self, index: usize) -> bool

Source

pub fn push_bit_string(&mut self, rhs: &Self)

Source

pub fn insert_bit_string(&mut self, index: usize, rhs: &Self)

Source

pub fn split_off(&mut self, at: usize) -> Self

Source

pub fn replace_interval(&mut self, interval: UsizeCO, replacement: &Self)

Source

pub fn drain_interval(&mut self, interval: UsizeCO) -> Self

Source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(bool) -> bool,

Source§

impl BitString

Source

pub fn slice(&self, interval: UsizeCO) -> Self

Source

pub fn slice_from(&self, start: usize) -> Self

Source

pub fn slice_until(&self, end: usize) -> Self

Source§

impl BitString

Source

pub fn iter(&self) -> Iter<'_>

Source§

impl BitString

Source

pub fn matches_at(&self, index: usize, pattern: &Self) -> bool

Source

pub fn starts_with(&self, prefix: &Self) -> bool

Source

pub fn ends_with(&self, suffix: &Self) -> bool

Source

pub fn contains(&self, needle: &Self) -> bool

Source

pub fn find(&self, needle: &Self) -> Option<usize>

Source

pub fn rfind(&self, needle: &Self) -> Option<usize>

Source

pub fn strip_prefix(&self, prefix: &Self) -> Option<Self>

Source

pub fn strip_suffix(&self, suffix: &Self) -> Option<Self>

Trait Implementations§

Source§

impl Clone for BitString

Source§

fn clone(&self) -> BitString

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BitString

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BitString

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for BitString

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for BitString

Source§

impl<'a> Extend<&'a bool> for BitString

Source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = &'a bool>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl Extend<bool> for BitString

Source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = bool>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<&[bool]> for BitString

Source§

fn from(values: &[bool]) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<[bool; N]> for BitString

Source§

fn from(values: [bool; N]) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<bool> for BitString

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = bool>,

Creates a value from an iterator. Read more
Source§

impl FromStr for BitString

Source§

type Err = ParseBitStringError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for BitString

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> IntoIterator for &'a BitString

Source§

type Item = bool

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for BitString

Source§

fn eq(&self, other: &BitString) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for BitString

Source§

impl TryFrom<&str> for BitString

Source§

type Error = ParseBitStringError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.