Skip to main content

FixedStr

Struct FixedStr 

Source
pub struct FixedStr<const N: usize>(/* private fields */);
Expand description

Stack-allocated, valid UTF-8 text with a fixed byte capacity.

Implementations§

Source§

impl<const N: usize> FixedStr<N>

Source

pub const fn new() -> Self

Creates an empty string.

Source

pub const fn len(&self) -> usize

Returns the UTF-8 byte length.

Source

pub const fn is_empty(&self) -> bool

Returns whether the string is empty.

Source

pub const fn capacity(&self) -> usize

Returns the maximum UTF-8 byte capacity.

Source

pub const fn remaining_capacity(&self) -> usize

Returns the remaining UTF-8 byte capacity.

Source

pub fn as_str(&self) -> &str

Returns the contents as a string slice.

Source

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

Returns the UTF-8 bytes.

Source

pub fn clear(&mut self)

Removes all text.

Source

pub fn try_push_str( &mut self, value: &str, ) -> Result<Range<usize>, CapacityError>

Appends text and returns its byte range.

Source

pub fn push_str(&mut self, value: &str) -> Range<usize>

Appends text and returns its byte range.

§Panics

Panics if the text exceeds the remaining capacity.

Source

pub fn try_push(&mut self, value: char) -> Result<Range<usize>, CapacityError>

Appends one Unicode scalar and returns its UTF-8 byte range.

Source

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

Shortens the string to new_len UTF-8 bytes.

§Panics

Panics unless new_len is a character boundary within the string.

Source

pub const fn into_bytes(self) -> FixedBytes<N>

Converts the string into its fixed byte buffer.

Trait Implementations§

Source§

impl<const N: usize> Clone for FixedStr<N>

Source§

fn clone(&self) -> FixedStr<N>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Copy for FixedStr<N>

Source§

impl<const N: usize> Debug for FixedStr<N>

Source§

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

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

impl<const N: usize> Default for FixedStr<N>

Source§

fn default() -> Self

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

impl<const N: usize> Display for FixedStr<N>

Source§

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

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

impl<const N: usize> Eq for FixedStr<N>

Source§

impl<const N: usize> PartialEq for FixedStr<N>

Source§

fn eq(&self, other: &FixedStr<N>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<const N: usize> StructuralPartialEq for FixedStr<N>

Source§

impl<const N: usize> TryFrom<&str> for FixedStr<N>

Source§

type Error = CapacityError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<FixedBytes<N>> for FixedStr<N>

Source§

type Error = Utf8Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: FixedBytes<N>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<const N: usize> Freeze for FixedStr<N>

§

impl<const N: usize> RefUnwindSafe for FixedStr<N>

§

impl<const N: usize> Send for FixedStr<N>

§

impl<const N: usize> Sync for FixedStr<N>

§

impl<const N: usize> Unpin for FixedStr<N>

§

impl<const N: usize> UnsafeUnpin for FixedStr<N>

§

impl<const N: usize> UnwindSafe for FixedStr<N>

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

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