ascii

Struct AsciiString

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

A growable string stored as an ASCII encoded buffer.

Implementations§

Source§

impl AsciiString

Source

pub fn new() -> Self

Creates a new, empty ASCII string buffer without allocating.

§Examples
let mut s = AsciiString::new();
Source

pub fn with_capacity(capacity: usize) -> Self

Creates a new ASCII string buffer with the given capacity. The string will be able to hold exactly capacity bytes without reallocating. If capacity is 0, the ASCII string will not allocate.

§Examples
let mut s = AsciiString::with_capacity(10);
Source

pub unsafe fn from_raw_parts( buf: *mut AsciiChar, length: usize, capacity: usize, ) -> Self

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

§Safety

This is highly unsafe, due to the number of invariants that aren’t checked:

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

Violating these may cause problems like corrupting the allocator’s internal datastructures.

§Examples

Basic usage:

use std::mem;

unsafe {
   let s = AsciiString::from_ascii("hello").unwrap();
   let ptr = s.as_ptr();
   let len = s.len();
   let capacity = s.capacity();

   mem::forget(s);

   let s = AsciiString::from_raw_parts(ptr as *mut _, len, capacity);

   assert_eq!(AsciiString::from_ascii("hello").unwrap(), s);
}
Source

pub unsafe fn from_ascii_unchecked<B>(bytes: B) -> Self
where B: Into<Vec<u8>>,

Converts a vector of bytes to an AsciiString without checking for non-ASCII characters.

§Safety

This function is unsafe because it does not check that the bytes passed to it are valid ASCII characters. If this constraint is violated, it may cause memory unsafety issues with future of the AsciiString, as the rest of this library assumes that AsciiStrings are ASCII encoded.

Source

pub fn from_ascii<B>(bytes: B) -> Result<AsciiString, FromAsciiError<B>>
where B: Into<Vec<u8>> + AsRef<[u8]>,

Converts anything that can represent a byte buffer into an AsciiString.

§Failure

Returns the byte buffer if not all of the bytes are ASCII characters.

§Examples
let foo = AsciiString::from_ascii("foo".to_string()).unwrap();
let err = AsciiString::from_ascii("Ŋ".to_string()).unwrap_err();
assert_eq!(foo.as_str(), "foo");
assert_eq!(err.into_source(), "Ŋ");
Source

pub fn push_str(&mut self, string: &AsciiStr)

Pushes the given ASCII string onto this ASCII string buffer.

§Examples
use std::str::FromStr;
let mut s = AsciiString::from_str("foo").unwrap();
s.push_str("bar".as_ascii_str().unwrap());
assert_eq!(s, "foobar".as_ascii_str().unwrap());
Source

pub fn capacity(&self) -> usize

Returns the number of bytes that this ASCII string buffer can hold without reallocating.

§Examples
let s = String::with_capacity(10);
assert!(s.capacity() >= 10);
Source

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

Reserves capacity for at least additional more bytes to be inserted in the given AsciiString. The collection may reserve more space to avoid frequent reallocations.

§Panics

Panics if the new capacity overflows usize.

§Examples
let mut s = AsciiString::new();
s.reserve(10);
assert!(s.capacity() >= 10);
Source

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

Reserves the minimum capacity for exactly additional more bytes to be inserted in the given AsciiString. Does nothing if the capacity is already sufficient.

Note that the allocator may give the collection more space than it requests. Therefore capacity can not be relied upon to be precisely minimal. Prefer reserve if future insertions are expected.

§Panics

Panics if the new capacity overflows usize.

§Examples
let mut s = AsciiString::new();
s.reserve_exact(10);
assert!(s.capacity() >= 10);
Source

pub fn shrink_to_fit(&mut self)

Shrinks the capacity of this ASCII string buffer to match it’s length.

§Examples
use std::str::FromStr;
let mut s = AsciiString::from_str("foo").unwrap();
s.reserve(100);
assert!(s.capacity() >= 100);
s.shrink_to_fit();
assert_eq!(s.capacity(), 3);
Source

pub fn push(&mut self, ch: AsciiChar)

Adds the given ASCII character to the end of the ASCII string.

§Examples
let mut s = AsciiString::from_ascii("abc").unwrap();
s.push(AsciiChar::from('1').unwrap());
s.push(AsciiChar::from('2').unwrap());
s.push(AsciiChar::from('3').unwrap());
assert_eq!(s, "abc123");
Source

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

Shortens a ASCII string to the specified length.

§Panics

Panics if new_len > current length.

§Examples
let mut s = AsciiString::from_ascii("hello").unwrap();
s.truncate(2);
assert_eq!(s, "he");
Source

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

Removes the last character from the ASCII string buffer and returns it. Returns None if this string buffer is empty.

§Examples
let mut s = AsciiString::from_ascii("foo").unwrap();
assert_eq!(s.pop().map(|c| c.as_char()), Some('o'));
assert_eq!(s.pop().map(|c| c.as_char()), Some('o'));
assert_eq!(s.pop().map(|c| c.as_char()), Some('f'));
assert_eq!(s.pop(), None);
Source

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

Removes the ASCII character at position idx from the buffer and returns it.

§Warning

This is an O(n) operation as it requires copying every element in the buffer.

§Panics

If idx is out of bounds this function will panic.

§Examples
let mut s = AsciiString::from_ascii("foo").unwrap();
assert_eq!(s.remove(0).as_char(), 'f');
assert_eq!(s.remove(1).as_char(), 'o');
assert_eq!(s.remove(0).as_char(), 'o');
Source

pub fn insert(&mut self, idx: usize, ch: AsciiChar)

Inserts an ASCII character into the buffer at position idx.

§Warning

This is an O(n) operation as it requires copying every element in the buffer.

§Panics

If idx is out of bounds this function will panic.

§Examples
let mut s = AsciiString::from_ascii("foo").unwrap();
s.insert(2, AsciiChar::b);
assert_eq!(s, "fobo");
Source

pub fn len(&self) -> usize

Returns the number of bytes in this ASCII string.

§Examples
let s = AsciiString::from_ascii("foo").unwrap();
assert_eq!(s.len(), 3);
Source

pub fn is_empty(&self) -> bool

Returns true if the ASCII string contains zero bytes.

§Examples
let mut s = AsciiString::new();
assert!(s.is_empty());
s.push(AsciiChar::from('a').unwrap());
assert!(!s.is_empty());
Source

pub fn clear(&mut self)

Truncates the ASCII string, setting length (but not capacity) to zero.

§Examples
let mut s = AsciiString::from_ascii("foo").unwrap();
s.clear();
assert!(s.is_empty());

Methods from Deref<Target = AsciiStr>§

Source

pub fn as_str(&self) -> &str

Converts &self to a &str slice.

Source

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

Converts &self into a byte slice.

Source

pub fn as_slice(&self) -> &[AsciiChar]

Returns the entire string as slice of AsciiChars.

Source

pub fn as_mut_slice(&mut self) -> &mut [AsciiChar]

Returns the entire string as mutable slice of AsciiChars.

Source

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

Returns a raw pointer to the AsciiStr’s buffer.

The caller must ensure that the slice outlives the pointer this function returns, or else it will end up pointing to garbage. Modifying the AsciiStr may cause it’s buffer to be reallocated, which would also make any pointers to it invalid.

Source

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

Returns an unsafe mutable pointer to the AsciiStr’s buffer.

The caller must ensure that the slice outlives the pointer this function returns, or else it will end up pointing to garbage. Modifying the AsciiStr may cause it’s buffer to be reallocated, which would also make any pointers to it invalid.

Source

pub fn to_ascii_string(&self) -> AsciiString

Copies the content of this AsciiStr into an owned AsciiString.

Source

pub fn len(&self) -> usize

Returns the number of characters / bytes in this ASCII sequence.

§Examples
let s = AsciiStr::from_ascii("foo").unwrap();
assert_eq!(s.len(), 3);
Source

pub fn is_empty(&self) -> bool

Returns true if the ASCII slice contains zero bytes.

§Examples
let mut empty = AsciiStr::from_ascii("").unwrap();
let mut full = AsciiStr::from_ascii("foo").unwrap();
assert!(empty.is_empty());
assert!(!full.is_empty());
Source

pub fn chars(&self) -> Chars<'_>

Returns an iterator over the characters of the AsciiStr.

Source

pub fn chars_mut(&mut self) -> CharsMut<'_>

Returns an iterator over the characters of the AsciiStr which allows you to modify the value of each AsciiChar.

Source

pub fn split(&self, on: AsciiChar) -> Split<'_>

Returns an iterator over parts of the AsciiStr separated by a character.

§Examples
let words = AsciiStr::from_ascii("apple banana lemon").unwrap()
    .split(AsciiChar::Space)
    .map(|a| a.as_str())
    .collect::<Vec<_>>();
assert_eq!(words, ["apple", "banana", "lemon"]);
Source

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

Returns an iterator over the lines of the AsciiStr, which are themselves AsciiStrs.

Lines are ended with either LineFeed (\n), or CarriageReturn then LineFeed (\r\n).

The final line ending is optional.

Source

pub fn trim(&self) -> &Self

Returns an ASCII string slice with leading and trailing whitespace removed.

§Examples
let example = AsciiStr::from_ascii("  \twhite \tspace  \t").unwrap();
assert_eq!("white \tspace", example.trim());
Source

pub fn trim_left(&self) -> &Self

Returns an ASCII string slice with leading whitespace removed.

§Examples
let example = AsciiStr::from_ascii("  \twhite \tspace  \t").unwrap();
assert_eq!("white \tspace  \t", example.trim_left());
Source

pub fn trim_right(&self) -> &Self

Returns an ASCII string slice with trailing whitespace removed.

§Examples
let example = AsciiStr::from_ascii("  \twhite \tspace  \t").unwrap();
assert_eq!("  \twhite \tspace", example.trim_right());
Source

pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool

Compares two strings case-insensitively.

Source

pub fn make_ascii_uppercase(&mut self)

Replaces lowercase letters with their uppercase equivalent.

Source

pub fn make_ascii_lowercase(&mut self)

Replaces uppercase letters with their lowercase equivalent.

Source

pub fn to_ascii_uppercase(&self) -> AsciiString

Returns a copy of this string where letters ‘a’ to ‘z’ are mapped to ‘A’ to ‘Z’.

Source

pub fn to_ascii_lowercase(&self) -> AsciiString

Returns a copy of this string where letters ‘A’ to ‘Z’ are mapped to ‘a’ to ‘z’.

Source

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

Returns the first character if the string is not empty.

Source

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

Returns the last character if the string is not empty.

Trait Implementations§

Source§

impl<'a> Add<&'a AsciiStr> for AsciiString

Source§

type Output = AsciiString

The resulting type after applying the + operator.
Source§

fn add(self, other: &AsciiStr) -> AsciiString

Performs the + operation. Read more
Source§

impl<'a> AddAssign<&'a AsciiStr> for AsciiString

Source§

fn add_assign(&mut self, other: &AsciiStr)

Performs the += operation. Read more
Source§

impl AsMut<[AsciiChar]> for AsciiString

Source§

fn as_mut(&mut self) -> &mut [AsciiChar]

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

impl AsMut<AsciiStr> for AsciiString

Source§

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

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

impl AsRef<[AsciiChar]> for AsciiString

Source§

fn as_ref(&self) -> &[AsciiChar]

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

impl AsRef<[u8]> for AsciiString

Source§

fn as_ref(&self) -> &[u8]

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

impl AsRef<AsciiStr> for AsciiString

Source§

fn as_ref(&self) -> &AsciiStr

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

impl AsRef<str> for AsciiString

Source§

fn as_ref(&self) -> &str

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

impl Borrow<AsciiStr> for AsciiString

Source§

fn borrow(&self) -> &AsciiStr

Immutably borrows from an owned value. Read more
Source§

impl BorrowMut<AsciiStr> for AsciiString

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl Clone for AsciiString

Source§

fn clone(&self) -> AsciiString

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 AsciiString

Source§

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

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

impl Default for AsciiString

Source§

fn default() -> AsciiString

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

impl Deref for AsciiString

Source§

type Target = AsciiStr

The resulting type after dereferencing.
Source§

fn deref(&self) -> &AsciiStr

Dereferences the value.
Source§

impl DerefMut for AsciiString

Source§

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

Mutably dereferences the value.
Source§

impl Display for AsciiString

Source§

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

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

impl<'a> Extend<&'a AsciiChar> for AsciiString

Source§

fn extend<I: IntoIterator<Item = &'a AsciiChar>>(&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 AsciiStr> for AsciiString

Source§

fn extend<I: IntoIterator<Item = &'a AsciiStr>>(&mut self, iterable: 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<AsciiChar> for AsciiString

Source§

fn extend<I: IntoIterator<Item = AsciiChar>>(&mut self, iterable: 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<Cow<'a, AsciiStr>> for AsciiString

Source§

fn extend<I: IntoIterator<Item = Cow<'a, AsciiStr>>>(&mut self, iterable: 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 [AsciiChar]> for AsciiString

Source§

fn from(s: &'a [AsciiChar]) -> AsciiString

Converts to this type from the input type.
Source§

impl<'a> From<&'a AsciiStr> for AsciiString

Source§

fn from(s: &'a AsciiStr) -> Self

Converts to this type from the input type.
Source§

impl From<AsciiString> for Cow<'static, AsciiStr>

Source§

fn from(string: AsciiString) -> Cow<'static, AsciiStr>

Converts to this type from the input type.
Source§

impl<'a> From<Cow<'a, AsciiStr>> for AsciiString

Source§

fn from(cow: Cow<'a, AsciiStr>) -> AsciiString

Converts to this type from the input type.
Source§

impl From<Vec<AsciiChar>> for AsciiString

Source§

fn from(vec: Vec<AsciiChar>) -> Self

Converts to this type from the input type.
Source§

impl<'a> FromIterator<&'a AsciiStr> for AsciiString

Source§

fn from_iter<I: IntoIterator<Item = &'a AsciiStr>>(iter: I) -> AsciiString

Creates a value from an iterator. Read more
Source§

impl FromIterator<AsciiChar> for AsciiString

Source§

fn from_iter<I: IntoIterator<Item = AsciiChar>>(iter: I) -> AsciiString

Creates a value from an iterator. Read more
Source§

impl<'a> FromIterator<Cow<'a, AsciiStr>> for AsciiString

Source§

fn from_iter<I: IntoIterator<Item = Cow<'a, AsciiStr>>>(iter: I) -> AsciiString

Creates a value from an iterator. Read more
Source§

impl FromStr for AsciiString

Source§

type Err = AsAsciiStrError

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

fn from_str(s: &str) -> Result<AsciiString, AsAsciiStrError>

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

impl Hash for AsciiString

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<T> Index<T> for AsciiString
where AsciiStr: Index<T>,

Source§

type Output = <AsciiStr as Index<T>>::Output

The returned type after indexing.
Source§

fn index(&self, index: T) -> &<AsciiStr as Index<T>>::Output

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

impl<T> IndexMut<T> for AsciiString
where AsciiStr: IndexMut<T>,

Source§

fn index_mut(&mut self, index: T) -> &mut <AsciiStr as Index<T>>::Output

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

impl Into<String> for AsciiString

Source§

fn into(self) -> String

Converts this type into the (usually inferred) input type.
Source§

impl Into<Vec<u8>> for AsciiString

Source§

fn into(self) -> Vec<u8>

Converts this type into the (usually inferred) input type.
Source§

impl IntoAsciiString for AsciiString

Source§

unsafe fn into_ascii_string_unchecked(self) -> AsciiString

Convert to AsciiString without checking for non-ASCII characters.
Source§

fn into_ascii_string(self) -> Result<AsciiString, FromAsciiError<Self>>

Convert to AsciiString.
Source§

impl Ord for AsciiString

Source§

fn cmp(&self, other: &AsciiString) -> 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> PartialEq<&'a AsciiStr> for AsciiString

Source§

fn eq(&self, other: &&'a AsciiStr) -> bool

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

fn ne(&self, other: &&'a AsciiStr) -> bool

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

impl<'a> PartialEq<&'a str> for AsciiString

Source§

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

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

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

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

impl<'a> PartialEq<AsciiString> for &'a AsciiStr

Source§

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

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

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

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

impl<'a> PartialEq<AsciiString> for &'a str

Source§

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

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

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

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

impl<'a> PartialEq<AsciiString> for String

Source§

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

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

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

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

impl PartialEq<AsciiString> for str

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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<'a> PartialEq<String> for AsciiString

Source§

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

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

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

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

impl PartialEq<str> for AsciiString

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq for AsciiString

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialOrd for AsciiString

Source§

fn partial_cmp(&self, other: &AsciiString) -> Option<Ordering>

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

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

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

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

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

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

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

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

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

impl Write for AsciiString

Please note that the std::fmt::Result returned by these methods does not support transmission of an error other than that an error occurred.

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
Source§

fn write_char(&mut self, c: char) -> Result

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
Source§

impl Eq for AsciiString

Source§

impl StructuralPartialEq for AsciiString

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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.