[][src]Struct bstr::BStr

#[repr(transparent)]pub struct BStr { /* fields omitted */ }

A wrapper for &[u8] that provides convenient string oriented trait impls.

If you need ownership or a growable byte string buffer, then use BString.

Using a &BStr is just like using a &[u8], since BStr implements Deref to [u8]. So all methods available on [u8] are also available on BStr.

Representation

A &BStr has the same representation as a &str. That is, a &BStr is a fat pointer which consists of a pointer to some bytes and a length.

Trait implementations

The BStr type has a number of trait implementations, and in particular, defines equality and ordinal comparisons between &BStr, &str and &[u8] for convenience.

The Debug implementation for BStr shows its bytes as a normal string. For invalid UTF-8, hex escape sequences are used.

The Display implementation behaves as if BStr were first lossily converted to a str. Invalid UTF-8 bytes are substituted with the Unicode replacement codepoint, which looks like this: �.

Trait Implementations

impl AsMut<[u8]> for BStr[src]

impl AsMut<BStr> for BString[src]

impl AsMut<BStr> for [u8][src]

impl AsRef<[u8]> for BStr[src]

impl AsRef<BStr> for BString[src]

impl AsRef<BStr> for [u8][src]

impl AsRef<BStr> for str[src]

impl Borrow<BStr> for BString[src]

impl Debug for BStr[src]

impl<'a> Default for &'a BStr[src]

impl<'a> Default for &'a mut BStr[src]

impl Deref for BStr[src]

type Target = [u8]

The resulting type after dereferencing.

impl DerefMut for BStr[src]

impl Display for BStr[src]

impl Eq for BStr[src]

impl<'a> From<&'a [u8]> for &'a BStr[src]

impl<'a> From<&'a BStr> for BString[src]

impl<'a> From<&'a BStr> for Cow<'a, BStr>[src]

impl<'a> From<&'a str> for &'a BStr[src]

impl<'a> FromIterator<&'a BStr> for BString[src]

impl Hash for BStr[src]

impl Index<Range<usize>> for BStr[src]

type Output = BStr

The returned type after indexing.

impl Index<RangeFrom<usize>> for BStr[src]

type Output = BStr

The returned type after indexing.

impl Index<RangeFull> for BStr[src]

type Output = BStr

The returned type after indexing.

impl Index<RangeInclusive<usize>> for BStr[src]

type Output = BStr

The returned type after indexing.

impl Index<RangeTo<usize>> for BStr[src]

type Output = BStr

The returned type after indexing.

impl Index<RangeToInclusive<usize>> for BStr[src]

type Output = BStr

The returned type after indexing.

impl Index<usize> for BStr[src]

type Output = u8

The returned type after indexing.

impl IndexMut<Range<usize>> for BStr[src]

impl IndexMut<RangeFrom<usize>> for BStr[src]

impl IndexMut<RangeFull> for BStr[src]

impl IndexMut<RangeInclusive<usize>> for BStr[src]

impl IndexMut<RangeTo<usize>> for BStr[src]

impl IndexMut<RangeToInclusive<usize>> for BStr[src]

impl IndexMut<usize> for BStr[src]

impl Ord for BStr[src]

impl<'a, 'b> PartialEq<&'a [u8]> for BStr[src]

impl<'a, 'b> PartialEq<&'a BStr> for BString[src]

impl<'a, 'b> PartialEq<&'a BStr> for Vec<u8>[src]

impl<'a, 'b> PartialEq<&'a BStr> for String[src]

impl<'a, 'b> PartialEq<&'a BStr> for Cow<'a, BStr>[src]

impl<'a, 'b> PartialEq<&'a BStr> for Cow<'a, str>[src]

impl<'a, 'b> PartialEq<&'a BStr> for Cow<'a, [u8]>[src]

impl<'a, 'b> PartialEq<&'a str> for BStr[src]

impl<'a, 'b> PartialEq<[u8]> for BStr[src]

impl<'a, 'b> PartialEq<BStr> for BString[src]

impl PartialEq<BStr> for BStr[src]

impl<'a, 'b> PartialEq<BStr> for [u8][src]

impl<'a, 'b> PartialEq<BStr> for &'a [u8][src]

impl<'a, 'b> PartialEq<BStr> for str[src]

impl<'a, 'b> PartialEq<BStr> for &'a str[src]

impl<'a, 'b> PartialEq<BStr> for Vec<u8>[src]

impl<'a, 'b> PartialEq<BStr> for String[src]

impl<'a, 'b> PartialEq<BString> for BStr[src]

impl<'a, 'b> PartialEq<BString> for &'a BStr[src]

impl<'a, 'b> PartialEq<Cow<'a, [u8]>> for &'a BStr[src]

impl<'a, 'b> PartialEq<Cow<'a, BStr>> for &'a BStr[src]

impl<'a, 'b> PartialEq<Cow<'a, str>> for &'a BStr[src]

impl<'a, 'b> PartialEq<String> for BStr[src]

impl<'a, 'b> PartialEq<String> for &'a BStr[src]

impl<'a, 'b> PartialEq<Vec<u8>> for BStr[src]

impl<'a, 'b> PartialEq<Vec<u8>> for &'a BStr[src]

impl<'a, 'b> PartialEq<str> for BStr[src]

impl<'a, 'b> PartialOrd<&'a [u8]> for BStr[src]

impl<'a, 'b> PartialOrd<&'a BStr> for BString[src]

impl<'a, 'b> PartialOrd<&'a BStr> for Vec<u8>[src]

impl<'a, 'b> PartialOrd<&'a BStr> for String[src]

impl<'a, 'b> PartialOrd<&'a str> for BStr[src]

impl<'a, 'b> PartialOrd<[u8]> for BStr[src]

impl<'a, 'b> PartialOrd<BStr> for BString[src]

impl PartialOrd<BStr> for BStr[src]

impl<'a, 'b> PartialOrd<BStr> for [u8][src]

impl<'a, 'b> PartialOrd<BStr> for &'a [u8][src]

impl<'a, 'b> PartialOrd<BStr> for str[src]

impl<'a, 'b> PartialOrd<BStr> for &'a str[src]

impl<'a, 'b> PartialOrd<BStr> for Vec<u8>[src]

impl<'a, 'b> PartialOrd<BStr> for String[src]

impl<'a, 'b> PartialOrd<BString> for BStr[src]

impl<'a, 'b> PartialOrd<BString> for &'a BStr[src]

impl<'a, 'b> PartialOrd<String> for BStr[src]

impl<'a, 'b> PartialOrd<String> for &'a BStr[src]

impl<'a, 'b> PartialOrd<Vec<u8>> for BStr[src]

impl<'a, 'b> PartialOrd<Vec<u8>> for &'a BStr[src]

impl<'a, 'b> PartialOrd<str> for BStr[src]

impl ToOwned for BStr[src]

type Owned = BString

The resulting type after obtaining ownership.

Auto Trait Implementations

impl RefUnwindSafe for BStr

impl Send for BStr

impl Sync for BStr

impl Unpin for BStr

impl UnwindSafe for BStr

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]