Struct ArrayStr
pub struct ArrayStr<const N: usize> { /* private fields */ }
A simple array-backed string type with a fixed capacity.
This is used by Jiff in lieu of a Box<str> for supporting core-only
environments without a dynamic memory allocator. For example, this is used
to represent time zone abbreviations which can be relied upon to be short.
N must be less than 256 so that its length can be represented by an
unsigned 8-bit integer.
An ArrayStr is guaranteed to be valid UTF-8.
Implementations
impl<const N: usize> ArrayStr<N>
const fn new(s: &str) -> Option<ArrayStr<N>>Creates a new fixed capacity string.
If the given string exceeds
Nbytes, then this returnsNone. Similarly, ifNexceedsu8::MAX, then this returnsNone.const fn capacity() -> usizeReturns the capacity of this array string.
fn push_str(&mut self, s: &str) -> boolAppend the bytes given to the end of this string.
If the capacity would be exceeded, then this is a no-op and
falseis returned. Otherwise, all ofsis written to this array string andtrueis returned.const fn as_str(&self) -> &strReturns this array string as a string slice.
Trait Implementations
impl<const N: usize> AsRef<str> for ArrayStr<N>
fn as_ref(&self) -> &str
impl<const N: usize> Clone for ArrayStr<N>
fn clone(&self) -> Self
impl<const N: usize> Copy for ArrayStr<N>
impl<const N: usize> Debug for ArrayStr<N>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<const N: usize> Deref for ArrayStr<N>
type Target = str;fn deref(&self) -> &str
impl<const N: usize> Display for ArrayStr<N>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<const N: usize> Eq for ArrayStr<N>
impl<const N: usize> Hash for ArrayStr<N>
fn hash<__H: Hasher>(&self, state: &mut __H)
impl<const N: usize> Ord for ArrayStr<N>
fn cmp(&self, other: &Self) -> Ordering
impl<const N: usize> PartialEq for ArrayStr<N>
fn eq(&self, other: &Self) -> bool
impl<const N: usize> PartialEq<&str> for ArrayStr<N>
fn eq(&self, rhs: &&str) -> bool
impl<const N: usize> PartialEq<str> for ArrayStr<N>
fn eq(&self, rhs: &str) -> bool
impl<const N: usize> PartialOrd for ArrayStr<N>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
impl<const N: usize> PartialOrd<&str> for ArrayStr<N>
fn partial_cmp(&self, rhs: &&str) -> Option<Ordering>
impl<const N: usize> PartialOrd<str> for ArrayStr<N>
fn partial_cmp(&self, rhs: &str) -> Option<Ordering>
impl<const N: usize> StructuralPartialEq for ArrayStr<N>
impl<const N: usize> Write for ArrayStr<N>
fn write_str(&mut self, s: &str) -> Result