[−][src]Struct string::String
A UTF-8 encoded string with configurable byte storage.
This type differs from std::String in that it is generic over the
underlying byte storage, enabling it to use Vec<[u8]>, &[u8], or third
party types, such as Bytes.
Methods
impl<T> String<T>[src]
pub fn get_ref(&self) -> &T[src]
Get a reference to the underlying byte storage.
Examples
let s = String::new(); let vec = s.get_ref();
pub unsafe fn get_mut(&mut self) -> &mut T[src]
Get a mutable reference to the underlying byte storage.
It is inadvisable to directly manipulate the byte storage. This function is unsafe as the bytes could no longer be valid UTF-8 after mutation.
Examples
let mut s = String::new(); unsafe { let vec = s.get_mut(); }
pub fn into_inner(self) -> T[src]
Unwraps this String, returning the underlying byte storage.
Examples
let s = String::new(); let vec = s.into_inner();
pub fn from_str<'a>(src: &'a str) -> String<T> where
T: From<&'a [u8]>, [src]
T: From<&'a [u8]>,
Creates a new String from a &str.
Use TryFrom for conversion from &[u8].
let _: String<Vec<u8>> = String::from_str("nice str");
impl String[src]
pub fn new() -> String[src]
Creates a new empty String.
Given that the String is empty, this will not allocate.
Examples
Basic usage
let s = String::new(); assert_eq!(s, "");
impl<T> String<T> where
T: AsRef<[u8]>, [src]
T: AsRef<[u8]>,
pub unsafe fn from_utf8_unchecked(value: T) -> String<T>[src]
Converts the provided value to a String without checking that the
given value is valid UTF-8.
Use TryFrom for a safe conversion.
Trait Implementations
impl<T> TryFrom<T> for String<T> where
T: AsRef<[u8]>, [src]
T: AsRef<[u8]>,
type Error = Utf8Error
The type returned in the event of a conversion error.
fn try_from(value: T) -> Result<Self, Self::Error>[src]
impl<T: PartialEq> PartialEq<String<T>> for String<T>[src]
impl<T> PartialEq<str> for String<T> where
T: AsRef<[u8]>, [src]
T: AsRef<[u8]>,
fn eq(&self, other: &str) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl<T: Default> Default for String<T>[src]
impl<T: Ord> Ord for String<T>[src]
fn cmp(&self, other: &String<T>) -> Ordering[src]
fn max(self, other: Self) -> Self1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
Compares and returns the minimum of two values. Read more
impl<T: Clone> Clone for String<T>[src]
fn clone(&self) -> String<T>[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl From<String> for String<String>[src]
impl<'a> From<&'a str> for String<&'a str>[src]
impl<T: Eq> Eq for String<T>[src]
impl<T: PartialOrd> PartialOrd<String<T>> for String<T>[src]
fn partial_cmp(&self, other: &String<T>) -> Option<Ordering>[src]
fn lt(&self, other: &String<T>) -> bool[src]
fn le(&self, other: &String<T>) -> bool[src]
fn gt(&self, other: &String<T>) -> bool[src]
fn ge(&self, other: &String<T>) -> bool[src]
impl<T: AsRef<[u8]>> Debug for String<T>[src]
impl<T: AsRef<[u8]>> Display for String<T>[src]
impl<T> DerefMut for String<T> where
T: AsRef<[u8]> + AsMut<[u8]>, [src]
T: AsRef<[u8]> + AsMut<[u8]>,
impl<T> Hash for String<T> where
T: AsRef<[u8]>, [src]
T: AsRef<[u8]>,
fn hash<H: Hasher>(&self, state: &mut H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher]. Read more
impl<T> Deref for String<T> where
T: AsRef<[u8]>, [src]
T: AsRef<[u8]>,
impl<T> Borrow<str> for String<T> where
T: AsRef<[u8]>, [src]
T: AsRef<[u8]>,
Auto Trait Implementations
Blanket Implementations
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T> From for T[src]
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
impl<T, U> TryFrom for T where
T: From<U>, [src]
T: From<U>,
type Error = !
try_from)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> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,