Struct BString

Source
pub struct BString { /* private fields */ }
Expand description

A growable byte string of unknown encoding.

It is analogous to the standard String type.

Its borrowed slice counterpart is the bstr type.

Implementations§

Source§

impl BString

Source

pub fn new() -> BString

Creates a new empty BString.

Source

pub fn with_capacity(n: usize) -> BString

Creates a new empty BString with the given capacity.

Source

pub fn concat<S: AsRef<bstr>>(strs: &[S]) -> BString

Returns a concatenated BString consisting of the given bstr values.

§Examples
use bstring::BString;

assert_eq!(BString::concat(&["hello", "world"]), "helloworld");
Source

pub fn join<Sep: AsRef<bstr>, S: AsRef<bstr>>(sep: Sep, strs: &[S]) -> BString

Returns a BString consisting of the given bstr values, joined together with the given separator.

§Examples
use bstring::BString;

assert_eq!(BString::join(" ", &["hello", "world"]), "hello world");
Source

pub unsafe fn from_raw_parts( ptr: *mut u8, length: usize, capacity: usize, ) -> BString

Creates a new BString from a pointer, length, and capacity.

§Safety

This is unsafe due to a number of invariants that are not checked:

  • The memory at ptr needs to have been previously allocated by the same allocator the standard library uses.
  • length needs to be less than or equal to capacity.
  • capacity needs to be the correct value.
Source

pub fn as_bstr(&self) -> &bstr

Returns a borrowed &bstr slice containing the entire string.

Source

pub fn as_mut_bstr(&mut self) -> &mut bstr

Returns a mutable &bstr slice containing the entire string.

Source

pub fn as_mut_vec(&mut self) -> &mut Vec<u8>

Returns a mutable reference to the internal Vec<u8>.

This method is safe because BString does not enforce any invariants over the content of its buffer. Any otherwise safe modifications may be made to the returned Vec.

Source

pub fn into_bytes(self) -> Vec<u8>

Consumes the BString and returns the internal Vec<u8>.

Source

pub fn into_string(self) -> Result<String, FromUtf8Error>

Attempts to the convert the BString into a String.

If the byte string does not contain valid UTF-8 data, an error is returned.

Source

pub fn push_str<S: AsRef<bstr>>(&mut self, s: S)

Appends bytes from a given byte string to this buffer.

§Examples
use bstring::BString;

let mut bs = BString::from("Rebecca");

bs.push_str(" Bunch");

assert_eq!(bs, "Rebecca Bunch");
Source

pub fn capacity(&self) -> usize

Returns the capacity of this BString, in bytes.

Source

pub fn reserve(&mut self, additional: usize)

Ensures that the BString capacity is at least additional bytes greater than its current length.

§Panics

If the new capacity overflows usize.

Source

pub fn reserve_exact(&mut self, additional: usize)

Ensures that the BString capacity is exactly additional bytes greater than its length.

§Panics

If the new the capacity overflows usize.

Source

pub fn shrink_to_fit(&mut self)

Shrinks the capacity of the BString to match its length.

Source

pub fn push(&mut self, b: u8)

Appends the given byte to end of this BString.

Source

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

Shortens the BString to the given length.

If new_len is greater than its current length, this has no effect.

This method does not affect the allocated capacity.

§Examples
use bstring::BString;

let mut bs = BString::from("Josh Chan");

bs.truncate(4);

assert_eq!(bs, "Josh");
Source

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

Removes and returns the last byte of the string.

Returns None if the string is empty.

Source

pub fn remove(&mut self, idx: usize) -> u8

Removes and returns the byte at the position idx.

§Panics

If idx is greater than or equal to the current length.

Source

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

Retains only the elements that satisfy the given predicate.

In other words, removes all elements for which f(&e) return false.

§Examples
use bstring::BString;

let mut bs = BString::from("pretzel");

bs.retain(|&b| b != b'e');

assert_eq!(bs, "prtzl");
Source

pub fn insert(&mut self, idx: usize, b: u8)

Inserts the given byte at position idx.

Source

pub fn insert_str<S: AsRef<bstr>>(&mut self, idx: usize, s: S)

Inserts a byte string at position idx.

§Examples
use bstring::BString;

let mut bs = BString::from("Covina");

bs.insert_str(0, "West ");

assert_eq!(bs, "West Covina");
Source

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

Splits the BString into two at the given index.

Returns a newly allocated BString. self contains bytes [0, at) and the returned BString contains bytes [at, len).

The capacity of self is not affected.

§Panics

If at is greater than the current length.

Source

pub fn clear(&mut self)

Truncates this BString, removing all contents.

The BString will have a length of zero, but its capacity will be unaffected.

Source

pub fn into_boxed_bstr(self) -> Box<bstr>

Converts this BString into a Box<bstr>.

This will drop any excess capacity.

Methods from Deref<Target = bstr>§

Source

pub fn len(&self) -> usize

Returns the length of the string, in bytes.

Source

pub fn is_empty(&self) -> bool

Returns whether the string is empty.

Source

pub fn as_bytes(&self) -> &[u8]

Returns a borrowed reference to the internal byte slice.

Source

pub fn as_mut_bytes(&mut self) -> &mut [u8]

Returns a mutable reference to the internal byte slice.

Source

pub fn as_ptr(&self) -> *const u8

Returns a raw pointer to the contained buffer.

Source

pub fn as_mut_ptr(&mut self) -> *mut u8

Returns a raw mutable pointer to the contained buffer.

Source

pub fn to_bstring(&self) -> BString

Returns a newly allocated BString buffer for the

Source

pub fn to_str(&self) -> Result<&str, Utf8Error>

Attempts to convert the byte string to a str slice.

If the byte string does not contain valid UTF-8, an error is returned.

Source

pub unsafe fn to_str_unchecked(&self) -> &str

Converts the byte string to a str slice.

§Safety

The byte string is assumed to contain valid UTF-8.

Source

pub fn to_string_lossy(&self) -> Cow<'_, str>

Converts the byte string a String.

During this conversion, any invalid UTF-8 sequences will be replaced with U+FFFD REPLACEMENT CHARACTER, which looks like this �

Source

pub fn display(&self) -> Display<'_>

Returns an object that implements Display for safely printing byte strings that may contain non-UTF-8 data.

Source

pub fn get(&self, idx: usize) -> Option<&u8>

Returns the byte at the given index.

Returns None if idx is greater than or equal to the string length.

Source

pub unsafe fn get_unchecked(&self, idx: usize) -> &u8

Returns the byte at the given index, bypassing bounds-checking.

§Safety

The caller of this function must guarantee that idx is less than the byte string length.

Source

pub unsafe fn slice_unchecked(&self, start: usize, end: usize) -> &bstr

Returns a subslice of this byte string, bypassing bounds-checking.

§Safety

The caller of this function must guarantee that:

  • start is less than or equal to end
  • end is less than or equal to the byte string length
Source

pub unsafe fn slice_mut_unchecked( &mut self, start: usize, end: usize, ) -> &mut bstr

Returns a mutable subslice of this byte string, bypassing bounds-checking.

§Safety

The caller of this function must guarantee that:

  • start is less than or equal to end
  • end is less than or equal to the byte string length
Source

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

Returns a borrowed reference to the first byte in the string.

Returns None if the byte string is empty.

Source

pub fn first_mut(&mut self) -> Option<&mut u8>

Returns a mutable reference to the first byte in the string.

Returns None if the byte string is empty.

Source

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

Returns a borrowed reference to the last byte in the string.

Returns None if the byte string is empty.

Source

pub fn last_mut(&mut self) -> Option<&mut u8>

Returns a mutable reference to the last byte in the string.

Returns None if the byte string is empty.

Source

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

Returns an iterator over the bytes of this string.

The element type of the returned iterator is &u8.

Source

pub fn iter_mut(&mut self) -> IterMut<'_>

Returns a mutable iterator over the bytes of this string.

The element type of the returned iterator is &mut u8.

Source

pub fn lines(&self) -> Lines<'_>

Returns an iterator over the lines of this byte string.

Lines may end with either a newline (\n) or a carriage return followed by a line feed (\r\n).

Yielded subslices will not contain the line ending.

Source

pub fn trim(&self) -> &bstr

Returns a subslice with leading and trailing whitespace removed.

Source

pub fn trim_left(&self) -> &bstr

Returns a subslice with leading whitespace removed.

Source

pub fn trim_right(&self) -> &bstr

Returns a subslice with trailing whitespace removed.

Source

pub fn trim_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &bstr

Returns a subslice with all matching prefixes and suffixes removed.

Source

pub fn trim_left_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &bstr

Returns a subslice with all matching prefixes removed.

Source

pub fn trim_right_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &bstr
where P::Searcher: ReverseSearcher<'a>,

Returns a subslice with all matching suffixes removed.

Source

pub fn partition<'a, P: Pattern<'a>>( &'a self, pat: P, ) -> Option<(&'a bstr, &'a bstr)>

Partitions the string using the given pattern.

The string is searched for the given pattern. If it is found, two subslices are returned: The portion of the string before the matching substring and the portion occurring after it.

§Examples
use bstring::bstr;

let bs = <&bstr>::from("foo=bar=baz");

let (a, b) = bs.partition(b'=').unwrap();

assert_eq!(a, "foo");
assert_eq!(b, "bar=baz");
Source

pub fn rpartition<'a, P: Pattern<'a>>( &'a self, pat: P, ) -> Option<(&'a bstr, &'a bstr)>
where P::Searcher: ReverseSearcher<'a>,

Partitions the string using the given pattern, searching from the end.

The string is searched for the given pattern, starting from the end. If it is found, two subslices are returned: The portion of the string before the matching substring and the portion occurring after it.

§Examples
use bstring::bstr;

let bs = <&bstr>::from("foo=bar=baz");

let (a, b) = bs.rpartition(b'=').unwrap();

assert_eq!(a, "foo=bar");
assert_eq!(b, "baz");
Source

pub fn split<'a, P: Pattern<'a>>(&'a self, pat: P) -> Split<'a, P>

Returns an iterator of subslices of this string, separated by a pattern.

Source

pub fn rsplit<'a, P: Pattern<'a>>(&'a self, pat: P) -> RSplit<'a, P>

Returns a reverse iterator of subslices of this string, separated by a pattern.

Source

pub fn splitn<'a, P: Pattern<'a>>( &'a self, count: usize, pat: P, ) -> SplitN<'a, P>

Returns an iterator of subslices of this string, separated by a pattern, limited to at most count items.

If count items are returned, the last item will contain the remainder of the string.

Source

pub fn rsplitn<'a, P: Pattern<'a>>( &'a self, count: usize, pat: P, ) -> RSplitN<'a, P>
where P::Searcher: ReverseSearcher<'a>,

Returns a reverse iterator of subslices of this string, separated by a pattern, limited to at most count items.

If count items are returned, the last item will contain the remainder of the string.

Source

pub fn split_terminator<'a, P: Pattern<'a>>( &'a self, pat: P, ) -> SplitTerminator<'a, P>

Returns an iterator of subslices of this string, separated by a pattern.

Equivalent to split, except that the final subslice is skipped if it is empty.

Source

pub fn rsplit_terminator<'a, P: Pattern<'a>>( &'a self, pat: P, ) -> RSplitTerminator<'a, P>
where P::Searcher: ReverseSearcher<'a>,

Returns a reverse iterator of subslices of this string, separated by a pattern.

Equivalent to rsplit, except that the final subslice is skipped if it is empty.

Source

pub fn split_words<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitWords<'a, P>

Returns an iterator of delimited words.

This differs from split in that multiple occurances of a pattern will be considered as one.

§Examples
use bstring::bstr;

let mut words = <&bstr>::from("   foo   bar   ").split_words(b' ');

assert_eq!(words.next().unwrap(), "foo");
assert_eq!(words.next().unwrap(), "bar");
assert_eq!(words.next(), None);
Source

pub fn matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> Matches<'a, P>

Returns an iterator over matches in the byte string.

Source

pub fn rmatches<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatches<'a, P>

Returns a reverse iterator over matches in the byte string.

Source

pub fn match_indices<'a, P: Pattern<'a>>( &'a self, pat: P, ) -> MatchIndices<'a, P>

Returns an iterator over matches in the byte string, including the index at which the match begins.

Source

pub fn rmatch_indices<'a, P: Pattern<'a>>( &'a self, pat: P, ) -> RMatchIndices<'a, P>

Returns a reverse iterator over matches in the byte string, including the index at which the match begins.

Source

pub fn split_at(&self, mid: usize) -> (&bstr, &bstr)

Returns the byte string divided into two at mid.

§Panics

If mid is beyond the end of the byte string.

Source

pub fn split_at_mut(&mut self, mid: usize) -> (&mut bstr, &mut bstr)

Returns the byte string divided into two at mid.

§Panics

If mid is beyond the end of the byte string.

Source

pub fn split_first(&self) -> Option<(&u8, &bstr)>

Returns the first byte and the rest, or None if the byte string is empty.

Source

pub fn split_first_mut(&mut self) -> Option<(&mut u8, &mut bstr)>

Returns the first byte and the rest, or None if the byte string is empty.

Source

pub fn split_last(&self) -> Option<(&u8, &bstr)>

Returns the last byte and the rest, or None if the byte string is empty.

Source

pub fn split_last_mut(&mut self) -> Option<(&mut u8, &mut bstr)>

Returns the last byte and the rest, or None if the byte string is empty.

Source

pub fn contains<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool

Returns whether the byte string contains the given pattern.

Source

pub fn starts_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool

Returns whether the byte string starts with the given pattern.

Source

pub fn ends_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool
where P::Searcher: ReverseSearcher<'a>,

Returns whether the byte string ends with the given pattern.

Source

pub fn find<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>

Returns the index of the first match of the given pattern.

Returns None if there is no match.

Source

pub fn rfind<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>
where P::Searcher: ReverseSearcher<'a>,

Returns the index of the first match of the given pattern, starting from the end.

Returns None if there is no match.

Source

pub fn parse<F: FromBStr>(&self) -> Result<F, F::Err>

Returns a value parsed from the byte string, using the FromBStr trait

Trait Implementations§

Source§

impl<'a> Add<&'a [u8]> for BString

Source§

type Output = BString

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &[u8]) -> Self

Performs the + operation. Read more
Source§

impl<'a> Add<&'a bstr> for BString

Source§

type Output = BString

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &bstr) -> Self

Performs the + operation. Read more
Source§

impl<'a> Add<&'a str> for BString

Source§

type Output = BString

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &str) -> Self

Performs the + operation. Read more
Source§

impl<'a> AddAssign<&'a [u8]> for BString

Source§

fn add_assign(&mut self, rhs: &[u8])

Performs the += operation. Read more
Source§

impl<'a> AddAssign<&'a bstr> for BString

Source§

fn add_assign(&mut self, rhs: &bstr)

Performs the += operation. Read more
Source§

impl<'a> AddAssign<&'a str> for BString

Source§

fn add_assign(&mut self, rhs: &str)

Performs the += operation. Read more
Source§

impl AsMut<bstr> for BString

Source§

fn as_mut(&mut self) -> &mut bstr

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<bstr> for BString

Source§

fn as_ref(&self) -> &bstr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<bstr> for BString

Source§

fn borrow(&self) -> &bstr

Immutably borrows from an owned value. Read more
Source§

impl Clone for BString

Source§

fn clone(&self) -> BString

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BString

Source§

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

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

impl Default for BString

Source§

fn default() -> BString

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

impl Deref for BString

Source§

type Target = bstr

The resulting type after dereferencing.
Source§

fn deref(&self) -> &bstr

Dereferences the value.
Source§

impl DerefMut for BString

Source§

fn deref_mut(&mut self) -> &mut bstr

Mutably dereferences the value.
Source§

impl Display for BString

Source§

fn bfmt(&self, f: &mut Formatter) -> Result

Formats the value using the given formatter.
Source§

impl<'a> Extend<&'a [u8]> for BString

Source§

fn extend<I: IntoIterator<Item = &'a [u8]>>(&mut self, iter: I)

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<'a> Extend<&'a bstr> for BString

Source§

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

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<'a> Extend<&'a str> for BString

Source§

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

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<'a> Extend<&'a u8> for BString

Source§

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

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<'a> Extend<BString> for BString

Source§

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

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<'a> Extend<String> for BString

Source§

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

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<'a> Extend<Vec<u8>> for BString

Source§

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

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<u8> for BString

Source§

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

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<'a> From<&'a [u8]> for BString

Source§

fn from(s: &[u8]) -> BString

Converts to this type from the input type.
Source§

impl<'a> From<&'a bstr> for BString

Source§

fn from(s: &bstr) -> BString

Converts to this type from the input type.
Source§

impl<'a> From<&'a str> for BString

Source§

fn from(s: &str) -> BString

Converts to this type from the input type.
Source§

impl From<String> for BString

Source§

fn from(s: String) -> BString

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for BString

Source§

fn from(v: Vec<u8>) -> BString

Converts to this type from the input type.
Source§

impl FromBStr for BString

Source§

type Err = ParseError

Error type returned from a failed parsing attempt.
Source§

fn from_bstr(s: &bstr) -> Result<BString, ParseError>

Parses a bstr to return this value.
Source§

impl FromIterator<u8> for BString

Source§

fn from_iter<I: IntoIterator<Item = u8>>(iter: I) -> BString

Creates a value from an iterator. Read more
Source§

impl Hash for BString

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 Index<Range<usize>> for BString

Source§

type Output = bstr

The returned type after indexing.
Source§

fn index(&self, r: Range<usize>) -> &bstr

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeFrom<usize>> for BString

Source§

type Output = bstr

The returned type after indexing.
Source§

fn index(&self, r: RangeFrom<usize>) -> &bstr

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeFull> for BString

Source§

type Output = bstr

The returned type after indexing.
Source§

fn index(&self, r: RangeFull) -> &bstr

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeTo<usize>> for BString

Source§

type Output = bstr

The returned type after indexing.
Source§

fn index(&self, r: RangeTo<usize>) -> &bstr

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<usize> for BString

Source§

type Output = u8

The returned type after indexing.
Source§

fn index(&self, idx: usize) -> &u8

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<Range<usize>> for BString

Source§

fn index_mut(&mut self, r: Range<usize>) -> &mut bstr

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<RangeFrom<usize>> for BString

Source§

fn index_mut(&mut self, r: RangeFrom<usize>) -> &mut bstr

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<RangeFull> for BString

Source§

fn index_mut(&mut self, r: RangeFull) -> &mut bstr

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<RangeTo<usize>> for BString

Source§

fn index_mut(&mut self, r: RangeTo<usize>) -> &mut bstr

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<usize> for BString

Source§

fn index_mut(&mut self, idx: usize) -> &mut u8

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a> IntoIterator for &'a BString

Source§

type Item = &'a u8

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<'a> IntoIterator for &'a mut BString

Source§

type Item = &'a mut u8

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'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 Ord for BString

Source§

fn cmp(&self, rhs: &BString) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'a, 'b> PartialEq<&'b [u8; 0]> for BString

Source§

fn eq(&self, rhs: &&[u8; 0]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 0]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 1]> for BString

Source§

fn eq(&self, rhs: &&[u8; 1]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 1]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 10]> for BString

Source§

fn eq(&self, rhs: &&[u8; 10]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 10]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 11]> for BString

Source§

fn eq(&self, rhs: &&[u8; 11]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 11]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 12]> for BString

Source§

fn eq(&self, rhs: &&[u8; 12]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 12]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 13]> for BString

Source§

fn eq(&self, rhs: &&[u8; 13]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 13]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 14]> for BString

Source§

fn eq(&self, rhs: &&[u8; 14]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 14]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 15]> for BString

Source§

fn eq(&self, rhs: &&[u8; 15]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 15]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 16]> for BString

Source§

fn eq(&self, rhs: &&[u8; 16]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 16]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 2]> for BString

Source§

fn eq(&self, rhs: &&[u8; 2]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 2]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 3]> for BString

Source§

fn eq(&self, rhs: &&[u8; 3]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 3]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 4]> for BString

Source§

fn eq(&self, rhs: &&[u8; 4]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 4]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 5]> for BString

Source§

fn eq(&self, rhs: &&[u8; 5]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 5]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 6]> for BString

Source§

fn eq(&self, rhs: &&[u8; 6]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 6]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 7]> for BString

Source§

fn eq(&self, rhs: &&[u8; 7]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 7]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 8]> for BString

Source§

fn eq(&self, rhs: &&[u8; 8]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 8]) -> bool

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

impl<'a, 'b> PartialEq<&'b [u8; 9]> for BString

Source§

fn eq(&self, rhs: &&[u8; 9]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&[u8; 9]) -> bool

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

impl<'a, 'b> PartialEq<&'a bstr> for BString

Source§

fn eq(&self, rhs: &&'a bstr) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&'a bstr) -> bool

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

impl<'a, 'b> PartialEq<&'a str> for BString

Source§

fn eq(&self, rhs: &&'a str) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &&'a str) -> bool

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

impl PartialEq<[u8]> for BString

Source§

fn eq(&self, rhs: &[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8]) -> bool

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

impl<'a> PartialEq<[u8; 0]> for BString

Source§

fn eq(&self, rhs: &[u8; 0]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 0]) -> bool

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

impl<'a> PartialEq<[u8; 1]> for BString

Source§

fn eq(&self, rhs: &[u8; 1]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 1]) -> bool

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

impl<'a> PartialEq<[u8; 10]> for BString

Source§

fn eq(&self, rhs: &[u8; 10]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 10]) -> bool

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

impl<'a> PartialEq<[u8; 11]> for BString

Source§

fn eq(&self, rhs: &[u8; 11]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 11]) -> bool

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

impl<'a> PartialEq<[u8; 12]> for BString

Source§

fn eq(&self, rhs: &[u8; 12]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 12]) -> bool

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

impl<'a> PartialEq<[u8; 13]> for BString

Source§

fn eq(&self, rhs: &[u8; 13]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 13]) -> bool

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

impl<'a> PartialEq<[u8; 14]> for BString

Source§

fn eq(&self, rhs: &[u8; 14]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 14]) -> bool

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

impl<'a> PartialEq<[u8; 15]> for BString

Source§

fn eq(&self, rhs: &[u8; 15]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 15]) -> bool

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

impl<'a> PartialEq<[u8; 16]> for BString

Source§

fn eq(&self, rhs: &[u8; 16]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 16]) -> bool

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

impl<'a> PartialEq<[u8; 2]> for BString

Source§

fn eq(&self, rhs: &[u8; 2]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 2]) -> bool

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

impl<'a> PartialEq<[u8; 3]> for BString

Source§

fn eq(&self, rhs: &[u8; 3]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 3]) -> bool

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

impl<'a> PartialEq<[u8; 4]> for BString

Source§

fn eq(&self, rhs: &[u8; 4]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 4]) -> bool

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

impl<'a> PartialEq<[u8; 5]> for BString

Source§

fn eq(&self, rhs: &[u8; 5]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 5]) -> bool

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

impl<'a> PartialEq<[u8; 6]> for BString

Source§

fn eq(&self, rhs: &[u8; 6]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 6]) -> bool

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

impl<'a> PartialEq<[u8; 7]> for BString

Source§

fn eq(&self, rhs: &[u8; 7]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 7]) -> bool

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

impl<'a> PartialEq<[u8; 8]> for BString

Source§

fn eq(&self, rhs: &[u8; 8]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 8]) -> bool

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

impl<'a> PartialEq<[u8; 9]> for BString

Source§

fn eq(&self, rhs: &[u8; 9]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &[u8; 9]) -> bool

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

impl<'a, 'b> PartialEq<BString> for &'a bstr

Source§

fn eq(&self, rhs: &BString) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &BString) -> bool

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

impl<'a, 'b> PartialEq<BString> for Cow<'a, bstr>

Source§

fn eq(&self, rhs: &BString) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &BString) -> bool

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

impl<'a, 'b> PartialEq<BString> for bstr

Source§

fn eq(&self, rhs: &BString) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &BString) -> bool

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

impl<'a, 'b> PartialEq<Cow<'a, bstr>> for BString

Source§

fn eq(&self, rhs: &Cow<'a, bstr>) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &Cow<'a, bstr>) -> bool

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

impl<'a, 'b> PartialEq<Cow<'a, str>> for BString

Source§

fn eq(&self, rhs: &Cow<'a, str>) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &Cow<'a, str>) -> bool

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

impl<'a, 'b> PartialEq<String> for BString

Source§

fn eq(&self, rhs: &String) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &String) -> bool

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

impl PartialEq<Vec<u8>> for BString

Source§

fn eq(&self, rhs: &Vec<u8>) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &Vec<u8>) -> bool

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

impl<'a, 'b> PartialEq<bstr> for BString

Source§

fn eq(&self, rhs: &bstr) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &bstr) -> bool

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

impl<'a, 'b> PartialEq<str> for BString

Source§

fn eq(&self, rhs: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &str) -> bool

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

impl<'a, 'b> PartialEq for BString

Source§

fn eq(&self, rhs: &BString) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &BString) -> bool

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

impl PartialOrd for BString

Source§

fn partial_cmp(&self, rhs: &BString) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
Source§

fn lt(&self, rhs: &BString) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
Source§

fn gt(&self, rhs: &BString) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
Source§

fn le(&self, rhs: &BString) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
Source§

fn ge(&self, rhs: &BString) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for BString

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

fn to_bstring(&self) -> BString

Returns a BString for the value.
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, 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.