Type Alias BoundedString

Source
pub type BoundedString = ArrayString<U63>;
Expand description

A fixed capacity copy-able string.

Aliased Typeยง

pub struct BoundedString { /* private fields */ }

Implementations

Sourceยง

impl<SIZE> ArrayString<SIZE>
where SIZE: Capacity,

Source

pub fn new() -> ArrayString<SIZE>

Creates new empty string.

let string = SmallString::new();
assert!(string.is_empty());
Source

pub fn try_from_str<S>(s: S) -> Result<ArrayString<SIZE>, OutOfBounds>
where S: AsRef<str>,

Creates new ArrayString from string slice if length is lower or equal to capacity, otherwise returns an error.

let string = SmallString::try_from_str("My String")?;
assert_eq!(string.as_str(), "My String");

assert_eq!(SmallString::try_from_str("")?.as_str(), "");

let out_of_bounds = "0".repeat(SmallString::capacity() as usize + 1);
assert!(SmallString::try_from_str(out_of_bounds).is_err());
Source

pub fn from_str_truncate<S>(string: S) -> ArrayString<SIZE>
where S: AsRef<str>,

Creates new ArrayString from string slice truncating size if bigger than capacity.

let string = SmallString::from_str_truncate("My String");
println!("{}", string);

let truncate = "0".repeat(SmallString::capacity() as usize + 1);
let truncated = "0".repeat(SmallString::capacity().into());
let string = SmallString::from_str_truncate(&truncate);
assert_eq!(string.as_str(), truncated);
Source

pub unsafe fn from_str_unchecked<S>(string: S) -> ArrayString<SIZE>
where S: AsRef<str>,

Creates new ArrayString from string slice assuming length is appropriate.

ยงSafety

Itโ€™s UB if string.len() > capacity.

let filled = "0".repeat(SmallString::capacity().into());
let string = unsafe {
    SmallString::from_str_unchecked(&filled)
};
assert_eq!(string.as_str(), filled.as_str());

// Undefined behavior, don't do it
// let out_of_bounds = "0".repeat(SmallString::capacity().into() + 1);
// let ub = unsafe { SmallString::from_str_unchecked(out_of_bounds) };
Source

pub fn try_from_iterator<U, I>( iter: I, ) -> Result<ArrayString<SIZE>, OutOfBounds>
where U: AsRef<str>, I: IntoIterator<Item = U>,

Creates new ArrayString from string slice iterator if total length is lower or equal to capacity, otherwise returns an error.

let string = MaxString::try_from_iterator(&["My String", " My Other String"][..])?;
assert_eq!(string.as_str(), "My String My Other String");

let out_of_bounds = (0..100).map(|_| "000");
assert!(SmallString::try_from_iterator(out_of_bounds).is_err());
Source

pub fn from_iterator<U, I>(iter: I) -> ArrayString<SIZE>
where U: AsRef<str>, I: IntoIterator<Item = U>,

Creates new ArrayString from string slice iterator truncating size if bigger than capacity.

let string = MaxString::from_iterator(&["My String", " Other String"][..]);
assert_eq!(string.as_str(), "My String Other String");

let out_of_bounds = (0..400).map(|_| "000");
let truncated = "0".repeat(SmallString::capacity().into());

let truncate = SmallString::from_iterator(out_of_bounds);
assert_eq!(truncate.as_str(), truncated.as_str());
Source

pub unsafe fn from_iterator_unchecked<U, I>(iter: I) -> ArrayString<SIZE>
where U: AsRef<str>, I: IntoIterator<Item = U>,

Creates new ArrayString from string slice iterator assuming length is appropriate.

ยงSafety

Itโ€™s UB if iter.map(|c| c.len()).sum() > capacity.

let string = unsafe {
    MaxString::from_iterator_unchecked(&["My String", " My Other String"][..])
};
assert_eq!(string.as_str(), "My String My Other String");

// Undefined behavior, don't do it
// let out_of_bounds = (0..400).map(|_| "000");
// let undefined_behavior = unsafe {
//     SmallString::from_iterator_unchecked(out_of_bounds)
// };
Source

pub fn try_from_chars<I>(iter: I) -> Result<ArrayString<SIZE>, OutOfBounds>
where I: IntoIterator<Item = char>,

Creates new ArrayString from char iterator if total length is lower or equal to capacity, otherwise returns an error.

let string = SmallString::try_from_chars("My String".chars())?;
assert_eq!(string.as_str(), "My String");

let out_of_bounds = "0".repeat(SmallString::capacity() as usize + 1);
assert!(SmallString::try_from_chars(out_of_bounds.chars()).is_err());
Source

pub fn from_chars<I>(iter: I) -> ArrayString<SIZE>
where I: IntoIterator<Item = char>,

Creates new ArrayString from char iterator truncating size if bigger than capacity.

let string = SmallString::from_chars("My String".chars());
assert_eq!(string.as_str(), "My String");

let out_of_bounds = "0".repeat(SmallString::capacity() as usize + 1);
let truncated = "0".repeat(SmallString::capacity().into());

let truncate = SmallString::from_chars(out_of_bounds.chars());
assert_eq!(truncate.as_str(), truncated.as_str());
Source

pub unsafe fn from_chars_unchecked<I>(iter: I) -> ArrayString<SIZE>
where I: IntoIterator<Item = char>,

Creates new ArrayString from char iterator assuming length is appropriate.

ยงSafety

Itโ€™s UB if iter.map(|c| c.len_utf8()).sum() > capacity.

let string = unsafe { SmallString::from_chars_unchecked("My String".chars()) };
assert_eq!(string.as_str(), "My String");

// Undefined behavior, don't do it
// let out_of_bounds = "000".repeat(400);
// let undefined_behavior = unsafe { SmallString::from_chars_unchecked(out_of_bounds.chars()) };
Source

pub fn try_from_utf8<B>(slice: B) -> Result<ArrayString<SIZE>, Error>
where B: AsRef<[u8]>,

Creates new ArrayString from byte slice, returning Utf8 on invalid utf-8 data or OutOfBounds if bigger than capacity

let string = SmallString::try_from_utf8("My String")?;
assert_eq!(string.as_str(), "My String");

let invalid_utf8 = [0, 159, 146, 150];
assert_eq!(SmallString::try_from_utf8(invalid_utf8), Err(Error::Utf8));

let out_of_bounds = "0000".repeat(400);
assert_eq!(SmallString::try_from_utf8(out_of_bounds.as_bytes()), Err(Error::OutOfBounds));
Source

pub fn from_utf8<B>(slice: B) -> Result<ArrayString<SIZE>, Utf8>
where B: AsRef<[u8]>,

Creates new ArrayString from byte slice, returning Utf8 on invalid utf-8 data, truncating if bigger than capacity.

let string = SmallString::from_utf8("My String")?;
assert_eq!(string.as_str(), "My String");

let invalid_utf8 = [0, 159, 146, 150];
assert_eq!(SmallString::from_utf8(invalid_utf8), Err(Utf8));

let out_of_bounds = "0".repeat(300);
assert_eq!(SmallString::from_utf8(out_of_bounds.as_bytes())?.as_str(),
           "0".repeat(SmallString::capacity().into()).as_str());
Source

pub unsafe fn from_utf8_unchecked<B>(slice: B) -> ArrayString<SIZE>
where B: AsRef<[u8]>,

Creates new ArrayString from byte slice assuming itโ€™s utf-8 and of a appropriate size.

ยงSafety

Itโ€™s UB if slice is not a valid utf-8 string or slice.len() > capacity.

let string = unsafe { SmallString::from_utf8_unchecked("My String") };
assert_eq!(string.as_str(), "My String");

// Undefined behavior, don't do it
// let out_of_bounds = "0".repeat(300);
// let ub = unsafe { SmallString::from_utf8_unchecked(out_of_bounds)) };
Source

pub fn try_from_utf16<B>(slice: B) -> Result<ArrayString<SIZE>, Error>
where B: AsRef<[u16]>,

Creates new ArrayString from u16 slice, returning Utf16 on invalid utf-16 data or OutOfBounds if bigger than capacity

let music = [0xD834, 0xDD1E, 0x006d, 0x0075, 0x0073, 0x0069, 0x0063];
let string = SmallString::try_from_utf16(music)?;
assert_eq!(string.as_str(), "๐„žmusic");

let invalid_utf16 = [0xD834, 0xDD1E, 0x006d, 0x0075, 0xD800, 0x0069, 0x0063];
assert_eq!(SmallString::try_from_utf16(invalid_utf16), Err(Error::Utf16));

let out_of_bounds: Vec<_> = (0..300).map(|_| 0).collect();
assert_eq!(SmallString::try_from_utf16(out_of_bounds), Err(Error::OutOfBounds));
Source

pub fn from_utf16<B>(slice: B) -> Result<ArrayString<SIZE>, Utf16>
where B: AsRef<[u16]>,

Creates new ArrayString from u16 slice, returning Utf16 on invalid utf-16 data, truncating if bigger than capacity.

let music = [0xD834, 0xDD1E, 0x006d, 0x0075, 0x0073, 0x0069, 0x0063];
let string = SmallString::from_utf16(music)?;
assert_eq!(string.as_str(), "๐„žmusic");

let invalid_utf16 = [0xD834, 0xDD1E, 0x006d, 0x0075, 0xD800, 0x0069, 0x0063];
assert_eq!(SmallString::from_utf16(invalid_utf16), Err(Utf16));

let out_of_bounds: Vec<u16> = (0..300).map(|_| 0).collect();
assert_eq!(SmallString::from_utf16(out_of_bounds)?.as_str(),
           "\0".repeat(SmallString::capacity().into()).as_str());
Source

pub fn from_utf16_lossy<B>(slice: B) -> ArrayString<SIZE>
where B: AsRef<[u16]>,

Creates new ArrayString from u16 slice, replacing invalid utf-16 data with REPLACEMENT_CHARACTER (\u{FFFD}) and truncating size if bigger than capacity

let music = [0xD834, 0xDD1E, 0x006d, 0x0075, 0x0073, 0x0069, 0x0063];
let string = SmallString::from_utf16_lossy(music);
assert_eq!(string.as_str(), "๐„žmusic");

let invalid_utf16 = [0xD834, 0xDD1E, 0x006d, 0x0075, 0xD800, 0x0069, 0x0063];
assert_eq!(SmallString::from_utf16_lossy(invalid_utf16).as_str(), "๐„žmu\u{FFFD}ic");

let out_of_bounds: Vec<u16> = (0..300).map(|_| 0).collect();
assert_eq!(SmallString::from_utf16_lossy(&out_of_bounds).as_str(),
           "\0".repeat(SmallString::capacity().into()).as_str());
Source

pub fn as_str(&self) -> &str

Extracts a string slice containing the entire ArrayString

let s = SmallString::try_from_str("My String")?;
assert_eq!(s.as_str(), "My String");
Source

pub fn as_mut_str(&mut self) -> &mut str

Extracts a mutable string slice containing the entire ArrayString

let mut s = SmallString::try_from_str("My String")?;
assert_eq!(s.as_mut_str(), "My String");
Source

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

Extracts a byte slice containing the entire ArrayString

let s = SmallString::try_from_str("My String")?;
assert_eq!(s.as_bytes(), "My String".as_bytes());
Source

pub unsafe fn as_mut_bytes(&mut self) -> &mut [u8] โ“˜

Extracts a mutable string slice containing the entire ArrayString

let mut s = SmallString::try_from_str("My String")?;
assert_eq!(unsafe { s.as_mut_bytes() }, "My String".as_bytes());
Source

pub fn capacity() -> u8

Returns maximum string capacity, defined at compile time, it will never change

assert_eq!(ArrayString::<typenum::U32>::capacity(), 32);
Source

pub fn try_push_str<S>(&mut self, string: S) -> Result<(), OutOfBounds>
where S: AsRef<str>,

Pushes string slice to the end of the ArrayString if total size is lower or equal to capacity, otherwise returns an error.

let mut s = MaxString::try_from_str("My String")?;
s.try_push_str(" My other String")?;
assert_eq!(s.as_str(), "My String My other String");

assert!(s.try_push_str("0".repeat(MaxString::capacity().into())).is_err());
Source

pub fn push_str<S>(&mut self, string: S)
where S: AsRef<str>,

Pushes string slice to the end of the ArrayString truncating total size if bigger than capacity.

let mut s = MaxString::try_from_str("My String")?;
s.push_str(" My other String");
assert_eq!(s.as_str(), "My String My other String");

let mut s = SmallString::default();
s.push_str("0".repeat(SmallString::capacity() as usize + 1));
assert_eq!(s.as_str(), "0".repeat(SmallString::capacity().into()).as_str());
Source

pub unsafe fn push_str_unchecked<S>(&mut self, string: S)
where S: AsRef<str>,

Pushes string slice to the end of the ArrayString assuming total size is appropriate.

ยงSafety

Itโ€™s UB if self.len() + string.len() > capacity.

let mut s = MaxString::try_from_str("My String")?;
unsafe { s.push_str_unchecked(" My other String") };
assert_eq!(s.as_str(), "My String My other String");

// Undefined behavior, don't do it
// let mut undefined_behavior = SmallString::default();
// undefined_behavior.push_str_unchecked("0".repeat(SmallString::capacity().into() + 1));
Source

pub fn try_push(&mut self, character: char) -> Result<(), OutOfBounds>

Inserts character to the end of the ArrayString erroring if total size if bigger than capacity.

let mut s = SmallString::try_from_str("My String")?;
s.try_push('!')?;
assert_eq!(s.as_str(), "My String!");

let mut s = SmallString::try_from_str(&"0".repeat(SmallString::capacity().into()))?;
assert!(s.try_push('!').is_err());
Source

pub unsafe fn push_unchecked(&mut self, ch: char)

Inserts character to the end of the ArrayString assuming length is appropriate

ยงSafety

Itโ€™s UB if self.len() + character.len_utf8() > capacity

let mut s = SmallString::try_from_str("My String")?;
unsafe { s.push_unchecked('!') };
assert_eq!(s.as_str(), "My String!");

// s = SmallString::try_from_str(&"0".repeat(SmallString::capacity().into()))?;
// Undefined behavior, don't do it
// s.push_unchecked('!');
Source

pub fn truncate(&mut self, size: u8) -> Result<(), Utf8>

Truncates ArrayString to specified size (if smaller than current size and a valid utf-8 char index).

let mut s = SmallString::try_from_str("My String")?;
s.truncate(5)?;
assert_eq!(s.as_str(), "My St");

// Does nothing
s.truncate(6)?;
assert_eq!(s.as_str(), "My St");

// Index is not at a valid char
let mut s = SmallString::try_from_str("๐Ÿค”")?;
assert!(s.truncate(1).is_err());
Source

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

Removes last character from ArrayString, if any.

let mut s = SmallString::try_from_str("A๐Ÿค”")?;
assert_eq!(s.pop(), Some('๐Ÿค”'));
assert_eq!(s.pop(), Some('A'));
assert_eq!(s.pop(), None);
Source

pub fn trim(&mut self)

Removes spaces from the beggining and end of the string

let mut string = MaxString::try_from_str("   to be trimmed     ")?;
string.trim();
assert_eq!(string.as_str(), "to be trimmed");

let mut string = SmallString::try_from_str("   ๐Ÿค”")?;
string.trim();
assert_eq!(string.as_str(), "๐Ÿค”");
Source

pub fn remove(&mut self, idx: u8) -> Result<char, Error>

Removes specified char from ArrayString

let mut s = SmallString::try_from_str("ABCD๐Ÿค”")?;
assert_eq!(s.remove("ABCD๐Ÿค”".len() as u8), Err(Error::OutOfBounds));
assert_eq!(s.remove(10), Err(Error::OutOfBounds));
assert_eq!(s.remove(6), Err(Error::Utf8));
assert_eq!(s.remove(0), Ok('A'));
assert_eq!(s.as_str(), "BCD๐Ÿค”");
assert_eq!(s.remove(2), Ok('D'));
assert_eq!(s.as_str(), "BC๐Ÿค”");
Source

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

Retains only the characters specified by the predicate.

let mut s = SmallString::try_from_str("ABCD๐Ÿค”")?;
s.retain(|c| c != '๐Ÿค”');
assert_eq!(s.as_str(), "ABCD");
Source

pub fn try_insert(&mut self, idx: u8, ch: char) -> Result<(), Error>

Inserts character at specified index, returning error if total length is bigger than capacity.

Returns OutOfBounds if idx is out of bounds and Utf8 if idx is not a char position

let mut s = SmallString::try_from_str("ABCD๐Ÿค”")?;
s.try_insert(1, 'A')?;
s.try_insert(2, 'B')?;
assert_eq!(s.as_str(), "AABBCD๐Ÿค”");
assert_eq!(s.try_insert(20, 'C'), Err(Error::OutOfBounds));
assert_eq!(s.try_insert(8, 'D'), Err(Error::Utf8));

let mut s = SmallString::try_from_str(&"0".repeat(SmallString::capacity().into()))?;
assert_eq!(s.try_insert(0, 'C'), Err(Error::OutOfBounds));
Source

pub unsafe fn insert_unchecked(&mut self, idx: u8, ch: char)

Inserts character at specified index assuming length is appropriate

ยงSafety

Itโ€™s UB if idx does not lie on a utf-8 char boundary

Itโ€™s UB if self.len() + character.len_utf8() > capacity

let mut s = SmallString::try_from_str("ABCD๐Ÿค”")?;
unsafe { s.insert_unchecked(1, 'A') };
unsafe { s.insert_unchecked(1, 'B') };
assert_eq!(s.as_str(), "ABABCD๐Ÿค”");

// Undefined behavior, don't do it
// s.insert(20, 'C');
// s.insert(8, 'D');
Source

pub fn try_insert_str<S>(&mut self, idx: u8, s: S) -> Result<(), Error>
where S: AsRef<str>,

Inserts string slice at specified index, returning error if total length is bigger than capacity.

Returns OutOfBounds if idx is out of bounds Returns Utf8 if idx is not a char position

let mut s = SmallString::try_from_str("ABCD๐Ÿค”")?;
s.try_insert_str(1, "AB")?;
s.try_insert_str(1, "BC")?;
assert_eq!(s.try_insert_str(1, "0".repeat(SmallString::capacity().into())),
           Err(Error::OutOfBounds));
assert_eq!(s.as_str(), "ABCABBCD๐Ÿค”");
assert_eq!(s.try_insert_str(20, "C"), Err(Error::OutOfBounds));
assert_eq!(s.try_insert_str(10, "D"), Err(Error::Utf8));
Source

pub fn insert_str<S>(&mut self, idx: u8, string: S) -> Result<(), Error>
where S: AsRef<str>,

Inserts string slice at specified index, truncating size if bigger than capacity.

Returns OutOfBounds if idx is out of bounds and Utf8 if idx is not a char position

let mut s = SmallString::try_from_str("ABCD๐Ÿค”")?;
s.insert_str(1, "AB")?;
s.insert_str(1, "BC")?;
assert_eq!(s.as_str(), "ABCABBCD๐Ÿค”");

assert_eq!(s.insert_str(20, "C"), Err(Error::OutOfBounds));
assert_eq!(s.insert_str(10, "D"), Err(Error::Utf8));

s.clear();
s.insert_str(0, "0".repeat(SmallString::capacity() as usize + 10))?;
assert_eq!(s.as_str(), "0".repeat(SmallString::capacity().into()).as_str());
Source

pub unsafe fn insert_str_unchecked<S>(&mut self, idx: u8, string: S)
where S: AsRef<str>,

Inserts string slice at specified index, assuming total length is appropriate.

ยงSafety

Itโ€™s UB if idx does not lie on a utf-8 char boundary

Itโ€™s UB if self.len() + string.len() > capacity

let mut s = SmallString::try_from_str("ABCD๐Ÿค”")?;
unsafe { s.insert_str_unchecked(1, "AB") };
unsafe { s.insert_str_unchecked(1, "BC") };
assert_eq!(s.as_str(), "ABCABBCD๐Ÿค”");

// Undefined behavior, don't do it
// unsafe { s.insert_str_unchecked(20, "C") };
// unsafe { s.insert_str_unchecked(10, "D") };
// unsafe { s.insert_str_unchecked(1, "0".repeat(SmallString::capacity().into())) };
Source

pub fn len(&self) -> u8

Returns ArrayString length.

let mut s = SmallString::try_from_str("ABCD")?;
assert_eq!(s.len(), 4);
s.try_push('๐Ÿค”')?;
// Emojis use 4 bytes (this is the default rust behavior, length of u8)
assert_eq!(s.len(), 8);
Source

pub fn is_empty(&self) -> bool

Checks if ArrayString is empty.

let mut s = SmallString::try_from_str("ABCD")?;
assert!(!s.is_empty());
s.clear();
assert!(s.is_empty());
Source

pub fn split_off(&mut self, at: u8) -> Result<ArrayString<SIZE>, Error>

Splits ArrayString in two if at is smaller than self.len().

Returns Utf8 if at does not lie at a valid utf-8 char boundary and OutOfBounds if itโ€™s out of bounds

let mut s = SmallString::try_from_str("AB๐Ÿค”CD")?;
assert_eq!(s.split_off(6)?.as_str(), "CD");
assert_eq!(s.as_str(), "AB๐Ÿค”");
assert_eq!(s.split_off(20), Err(Error::OutOfBounds));
assert_eq!(s.split_off(4), Err(Error::Utf8));
Source

pub fn clear(&mut self)

Empties ArrayString

let mut s = SmallString::try_from_str("ABCD")?;
assert!(!s.is_empty());
s.clear();
assert!(s.is_empty());
Source

pub fn drain<R>(&mut self, range: R) -> Result<Drain<SIZE>, Error>
where R: RangeBounds<u8>,

Creates a draining iterator that removes the specified range in the ArrayString and yields the removed chars.

Note: The element range is removed even if the iterator is not consumed until the end.

let mut s = SmallString::try_from_str("ABCD๐Ÿค”")?;
assert_eq!(s.drain(..3)?.collect::<Vec<_>>(), vec!['A', 'B', 'C']);
assert_eq!(s.as_str(), "D๐Ÿค”");

assert_eq!(s.drain(3..), Err(Error::Utf8));
assert_eq!(s.drain(10..), Err(Error::OutOfBounds));
Source

pub fn replace_range<S, R>(&mut self, r: R, with: S) -> Result<(), Error>
where S: AsRef<str>, R: RangeBounds<u8>,

Removes the specified range of the ArrayString, and replaces it with the given string. The given string doesnโ€™t need to have the same length as the range.

let mut s = SmallString::try_from_str("ABCD๐Ÿค”")?;
s.replace_range(2..4, "EFGHI")?;
assert_eq!(s.as_str(), "ABEFGHI๐Ÿค”");

assert_eq!(s.replace_range(9.., "J"), Err(Error::Utf8));
assert_eq!(s.replace_range(..90, "K"), Err(Error::OutOfBounds));
assert_eq!(s.replace_range(0..1, "0".repeat(SmallString::capacity().into())),
           Err(Error::OutOfBounds));

Trait Implementations

Sourceยง

impl<'a, SIZE> Add<&'a str> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

type Output = ArrayString<SIZE>

The resulting type after applying the + operator.
Sourceยง

fn add(self, other: &str) -> <ArrayString<SIZE> as Add<&'a str>>::Output

Performs the + operation. Read more
Sourceยง

impl<SIZE> AsMut<str> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

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

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

impl<SIZE> AsRef<[u8]> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn as_ref(&self) -> &[u8] โ“˜

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

impl<SIZE> AsRef<str> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn as_ref(&self) -> &str

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

impl<SIZE> Borrow<str> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
Sourceยง

impl<SIZE> BorrowMut<str> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

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

Mutably borrows from an owned value. Read more
Sourceยง

impl<SIZE> Clone for ArrayString<SIZE>
where SIZE: Clone + Capacity, <SIZE as Capacity>::Array: Clone,

Sourceยง

fn clone(&self) -> ArrayString<SIZE>

Returns a duplicate of the value. Read more
1.0.0 ยท Sourceยง

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

Performs copy-assignment from source. Read more
Sourceยง

impl<SIZE> Debug for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl<SIZE> Default for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn default() -> ArrayString<SIZE>

Returns the โ€œdefault valueโ€ for a type. Read more
Sourceยง

impl<SIZE> Deref for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

type Target = str

The resulting type after dereferencing.
Sourceยง

fn deref(&self) -> &<ArrayString<SIZE> as Deref>::Target

Dereferences the value.
Sourceยง

impl<SIZE> DerefMut for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn deref_mut(&mut self) -> &mut <ArrayString<SIZE> as Deref>::Target

Mutably dereferences the value.
Sourceยง

impl<SIZE> Display for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl<'a, SIZE> Extend<&'a char> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

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

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, SIZE> Extend<&'a str> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

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

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<SIZE> Extend<char> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn extend<I>(&mut self, iterable: I)
where I: IntoIterator<Item = char>,

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, SIZE> From<&'a str> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn from(s: &str) -> ArrayString<SIZE>

Converts to this type from the input type.
Sourceยง

impl<'a, SIZE> FromIterator<&'a str> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn from_iter<I>(iter: I) -> ArrayString<SIZE>
where I: IntoIterator<Item = &'a str>,

Creates a value from an iterator. Read more
Sourceยง

impl<SIZE> FromIterator<char> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn from_iter<I>(iter: I) -> ArrayString<SIZE>
where I: IntoIterator<Item = char>,

Creates a value from an iterator. Read more
Sourceยง

impl<SIZE> FromStr for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

type Err = OutOfBounds

The associated error which can be returned from parsing.
Sourceยง

fn from_str( s: &str, ) -> Result<ArrayString<SIZE>, <ArrayString<SIZE> as FromStr>::Err>

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

impl<SIZE> Hash for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn hash<H>(&self, hasher: &mut H)
where H: Hasher,

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<SIZE> Index<Range<u8>> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

type Output = str

The returned type after indexing.
Sourceยง

fn index( &self, index: Range<u8>, ) -> &<ArrayString<SIZE> as Index<Range<u8>>>::Output

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

impl<SIZE> Index<RangeFrom<u8>> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

type Output = str

The returned type after indexing.
Sourceยง

fn index( &self, index: RangeFrom<u8>, ) -> &<ArrayString<SIZE> as Index<RangeFrom<u8>>>::Output

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

impl<SIZE> Index<RangeFull> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

type Output = str

The returned type after indexing.
Sourceยง

fn index( &self, index: RangeFull, ) -> &<ArrayString<SIZE> as Index<RangeFull>>::Output

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

impl<SIZE> Index<RangeInclusive<u8>> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

type Output = str

The returned type after indexing.
Sourceยง

fn index( &self, index: RangeInclusive<u8>, ) -> &<ArrayString<SIZE> as Index<RangeInclusive<u8>>>::Output

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

impl<SIZE> Index<RangeTo<u8>> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

type Output = str

The returned type after indexing.
Sourceยง

fn index( &self, index: RangeTo<u8>, ) -> &<ArrayString<SIZE> as Index<RangeTo<u8>>>::Output

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

impl<SIZE> Index<RangeToInclusive<u8>> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

type Output = str

The returned type after indexing.
Sourceยง

fn index( &self, index: RangeToInclusive<u8>, ) -> &<ArrayString<SIZE> as Index<RangeToInclusive<u8>>>::Output

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

impl<SIZE> IndexMut<Range<u8>> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn index_mut(&mut self, index: Range<u8>) -> &mut str

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

impl<SIZE> IndexMut<RangeFrom<u8>> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn index_mut(&mut self, index: RangeFrom<u8>) -> &mut str

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

impl<SIZE> IndexMut<RangeFull> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn index_mut(&mut self, index: RangeFull) -> &mut str

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

impl<SIZE> IndexMut<RangeInclusive<u8>> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn index_mut(&mut self, index: RangeInclusive<u8>) -> &mut str

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

impl<SIZE> IndexMut<RangeTo<u8>> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn index_mut(&mut self, index: RangeTo<u8>) -> &mut str

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

impl<SIZE> IndexMut<RangeToInclusive<u8>> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn index_mut(&mut self, index: RangeToInclusive<u8>) -> &mut str

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

impl<SIZE> Ord for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn cmp(&self, other: &ArrayString<SIZE>) -> 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, SIZE> PartialEq<str> for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท Sourceยง

const 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<SIZE> PartialEq for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn eq(&self, other: &ArrayString<SIZE>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท Sourceยง

const 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<SIZE> PartialOrd for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn partial_cmp(&self, other: &ArrayString<SIZE>) -> 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<SIZE> Write for ArrayString<SIZE>
where SIZE: Capacity,

Sourceยง

fn write_str(&mut self, slice: &str) -> Result<(), Error>

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 ยท Sourceยง

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

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<SIZE> Copy for ArrayString<SIZE>
where SIZE: Capacity + Copy, <SIZE as Capacity>::Array: Copy,

Sourceยง

impl<SIZE> Eq for ArrayString<SIZE>
where SIZE: Capacity,