pub struct FromUtf8Error<const N: usize> { /* private fields */ }Implementations§
Source§impl<const N: usize> FromUtf8Error<N>
impl<const N: usize> FromUtf8Error<N>
Sourcepub fn into_bytes(self) -> SmallVec<u8, N>
pub fn into_bytes(self) -> SmallVec<u8, N>
Returns the bytes that were attempted to convert to a SmallStr.
This method is carefully constructed to avoid allocation. It will consume the error, moving out the bytes, so that a copy of the bytes does not need to be made.
§Examples
use small_str::SmallString;
// some invalid bytes, in a vector
let bytes = vec![0, 159];
let value = SmallString::from_utf8(bytes.into());
assert_eq!(vec![0, 159], value.unwrap_err().into_bytes().into_vec());Sourcepub fn utf8_error(&self) -> Utf8Error
pub fn utf8_error(&self) -> Utf8Error
Fetch a Utf8Error to get more details about the conversion failure.
The Utf8Error type provided by std::str represents an error that may
occur when converting a slice of u8s to a &str. In this sense, it’s
an analogue to FromUtf8Error. See its documentation for more details
on using it.
§Examples
use small_str::SmallString;
// some invalid bytes, in a vector
let bytes = vec![0, 159];
let error = SmallString::from_utf8(bytes.into()).unwrap_err().utf8_error();
// the first byte is invalid here
assert_eq!(1, error.valid_up_to());Trait Implementations§
Source§impl<const N: usize> Clone for FromUtf8Error<N>
impl<const N: usize> Clone for FromUtf8Error<N>
Source§fn clone(&self) -> FromUtf8Error<N>
fn clone(&self) -> FromUtf8Error<N>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<const N: usize> Debug for FromUtf8Error<N>
impl<const N: usize> Debug for FromUtf8Error<N>
Source§impl<const N: usize> Display for FromUtf8Error<N>
impl<const N: usize> Display for FromUtf8Error<N>
Source§impl<const N: usize> Error for FromUtf8Error<N>
Available on crate features unstable or std only.
impl<const N: usize> Error for FromUtf8Error<N>
Available on crate features
unstable or std only.Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
Source§impl<const N: usize> PartialEq for FromUtf8Error<N>
impl<const N: usize> PartialEq for FromUtf8Error<N>
impl<const N: usize> Eq for FromUtf8Error<N>
impl<const N: usize> StructuralPartialEq for FromUtf8Error<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for FromUtf8Error<N>
impl<const N: usize> RefUnwindSafe for FromUtf8Error<N>
impl<const N: usize> Send for FromUtf8Error<N>
impl<const N: usize> Sync for FromUtf8Error<N>
impl<const N: usize> Unpin for FromUtf8Error<N>
impl<const N: usize> UnwindSafe for FromUtf8Error<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more