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.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) -> ArrayStr<N>
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: &ArrayStr<N>) -> Ordering
impl<const N: usize> PartialEq for ArrayStr<N>
fn eq(&self, other: &ArrayStr<N>) -> 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: &ArrayStr<N>) -> 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
Auto Trait Implementations
impl<const N: usize> Freeze for ArrayStr<N>
where
[u8; N]: Freeze,
impl<const N: usize> RefUnwindSafe for ArrayStr<N>
where
[u8; N]: RefUnwindSafe,
impl<const N: usize> Send for ArrayStr<N>
where
[u8; N]: Send,
impl<const N: usize> Sync for ArrayStr<N>
where
[u8; N]: Sync,
impl<const N: usize> Unpin for ArrayStr<N>
where
[u8; N]: Unpin,
impl<const N: usize> UnsafeUnpin for ArrayStr<N>
where
[u8; N]: UnsafeUnpin,
impl<const N: usize> UnwindSafe for ArrayStr<N>
where
[u8; N]: UnwindSafe,
Blanket Implementations
impl<P, T> Receiver for ArrayStr<N>
where
P: Deref<Target = T> + ?Sized,
T: ?Sized,
type Target = T;
impl<T> Any for ArrayStr<N>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for ArrayStr<N>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for ArrayStr<N>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for ArrayStr<N>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for ArrayStr<N>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for ArrayStr<N>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> ToString for ArrayStr<N>
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for ArrayStr<N>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for ArrayStr<N>
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for ArrayStr<N>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>