[−][src]Struct bigbit::linkedbytes::LBString
A Unicode string stored using the Linked Bytes format.
This is more compact than all of the current UTF formats (namely, UTF-1, 7, 8, 16, let alone 32), since no surrogate pairs are used. Instead, the Linked Bytes format is leveraged, with separate codepoints being stored as individual Linked Bytes numbers. Both the link/end bits of the bytes and length of the entire message, either via the null terminator (which still works since a linking 0 has the most significant bit set to 1 and cannot be confused with the null terminator when reinterpreted as u8
) or via storing it separately (as Rust String
s do), are available. This means that the UTF-32 number of each codepoint can be encoded using the usual Linked Bytes format, with the link bit cleared in a byte indicating that one character has ended and a new one is coming next.
Usage
Conversion from String
or &str
:
static MY_STRING: &str = "My string!"; let stdstring = String::from("This is a standard string!"); let my_string_lb = LBString::from(MY_STRING); // Creates an LBString from a string slice let stdstring_lb = LBString::from(stdstring); // Creates an LBString from a String let my_string_lb_2 = MY_STRING.chars().collect::<LBString>(); // Creates an LBString from an iterator
Methods
impl LBString
[src]
pub fn chars(&self) -> impl Iterator<Item = char> + '_
[src]
Returns an iterator over the codepoints in the string.
This is the core method of this type. Most other methods use this to perform more complex operations, such as conversion from an &str
.
pub fn inner(&self) -> &LBSequence
[src]
Returns an immutable reference to the underlying sequence.
Trait Implementations
impl Clone for LBString
[src]
fn clone(&self) -> LBString
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for LBString
[src]
impl Display for LBString
[src]
impl<'_> From<&'_ String> for LBString
[src]
impl<'a> From<&'a str> for LBString
[src]
impl From<LBString> for String
[src]
impl From<String> for LBString
[src]
impl<'a> FromIterator<&'a char> for LBString
[src]
fn from_iter<I: IntoIterator<Item = &'a char>>(iter: I) -> Self
[src]
Convenience implementation for collections which iterate over references to items rather than the items themselves, to avoid repetitive .copied()
in calling code.
impl FromIterator<char> for LBString
[src]
fn from_iter<I: IntoIterator<Item = char>>(iter: I) -> Self
[src]
Auto Trait Implementations
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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>,