[−][src]Struct calf_vec::string::CalfString
Implementations
impl<'a, M: Meta, const N: usize> CalfString<'a, M, N>[src]
pub fn from_utf8<V: Into<CalfVec<'a, M, u8, N>>>(
vec: V
) -> Result<CalfString<'a, M, N>, FromUtf8Error<'a, M, N>>[src]
vec: V
) -> Result<CalfString<'a, M, N>, FromUtf8Error<'a, M, N>>
Converts a vector of bytes to a CalfString.
A string (String) is made of bytes (u8), and a vector of bytes
(Vec<u8>) is made of bytes, so this function converts between the
two. Not all byte slices are valid Strings, however: String
requires that it is valid UTF-8. from_utf8() checks to ensure that
the bytes are valid UTF-8, and then does the conversion.
If you are sure that the byte slice is valid UTF-8, and you don't want
to incur the overhead of the validity check, there is an unsafe version
of this function, [from_utf8_unchecked], which has the same behavior
but skips the check.
This method will take care to not copy the vector, for efficiency's sake.
The inverse of this method is [into_bytes].
Errors
Returns Err if the slice is not UTF-8 with a description as to why the
provided bytes are not UTF-8. The vector you moved in is also included.
pub fn len(&self) -> usize[src]
Returns this String's size, in bytes.
pub fn capacity(&self) -> Option<usize>[src]
Returns this String's capacity, in bytes.
pub fn reserve(&mut self, additional: usize)[src]
Ensures that this CalfString's capacity is at least additional bytes
larger than its length.
The capacity may be increased by more than additional bytes if it
chooses, to prevent frequent reallocations.
If you do not want this "at least" behavior, see the reserve_exact
method.
Panics
Panics if the new capacity overflows usize.
pub fn push(&mut self, ch: char)[src]
Appends the given char to the end of this CalfString.
pub fn as_bytes(&self) -> &[u8][src]
Returns a byte slice of this String's contents.
The inverse of this method is from_utf8.
pub fn truncate(&mut self, new_len: usize)[src]
Trait Implementations
impl<'a, M: Meta, const N: usize> Deref for CalfString<'a, M, N>[src]
impl<'a, M: Meta, const N: usize> DerefMut for CalfString<'a, M, N>[src]
Auto Trait Implementations
impl<'a, M, const N: usize> RefUnwindSafe for CalfString<'a, M, N> where
M: RefUnwindSafe,
M: RefUnwindSafe,
impl<'a, M, const N: usize> Send for CalfString<'a, M, N> where
M: Send,
M: Send,
impl<'a, M, const N: usize> Sync for CalfString<'a, M, N> where
M: Sync,
M: Sync,
impl<'a, M, const N: usize> Unpin for CalfString<'a, M, N> where
M: Unpin,
M: Unpin,
impl<'a, M, const N: usize> UnwindSafe for CalfString<'a, M, N> where
M: UnwindSafe,
M: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,