Struct alloc::ffi::FromVecWithNulError
source · [−]pub struct FromVecWithNulError { /* private fields */ }Expand description
An error indicating that a nul byte was not in the expected position.
The vector used to create a CString must have one and only one nul byte,
positioned at the end.
This error is created by the CString::from_vec_with_nul method.
See its documentation for more.
Examples
use std::ffi::{CString, FromVecWithNulError};
let _: FromVecWithNulError = CString::from_vec_with_nul(b"f\0oo".to_vec()).unwrap_err();RunImplementations
impl FromVecWithNulError
1.58.0 · source
impl FromVecWithNulError
1.58.0 · sourcepub fn into_bytes(self) -> Vec<u8>
1.58.0 · source
pub fn into_bytes(self) -> Vec<u8>
1.58.0 · sourceReturns the bytes that were attempted to convert to a CString.
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
Basic usage:
use std::ffi::CString;
// Some invalid bytes in a vector
let bytes = b"f\0oo".to_vec();
let value = CString::from_vec_with_nul(bytes.clone());
assert_eq!(bytes, value.unwrap_err().into_bytes());RunTrait Implementations
impl Clone for FromVecWithNulError
source
impl Clone for FromVecWithNulError
sourcefn clone(&self) -> FromVecWithNulError
source
fn clone(&self) -> FromVecWithNulError
sourceReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0 · source
fn clone_from(&mut self, source: &Self)
1.0.0 · sourcePerforms copy-assignment from source. Read more
impl Debug for FromVecWithNulError
source
impl Debug for FromVecWithNulError
sourceimpl Display for FromVecWithNulError
1.58.0 · source
impl Display for FromVecWithNulError
1.58.0 · sourceimpl PartialEq<FromVecWithNulError> for FromVecWithNulError
source
impl PartialEq<FromVecWithNulError> for FromVecWithNulError
sourcefn eq(&self, other: &FromVecWithNulError) -> bool
source
fn eq(&self, other: &FromVecWithNulError) -> bool
sourceThis method tests for self and other values to be equal, and is used
by ==. Read more
fn ne(&self, other: &FromVecWithNulError) -> bool
source
fn ne(&self, other: &FromVecWithNulError) -> bool
sourceThis method tests for !=.
impl Eq for FromVecWithNulError
sourceimpl StructuralEq for FromVecWithNulError
sourceimpl StructuralPartialEq for FromVecWithNulError
sourceAuto Trait Implementations
impl RefUnwindSafe for FromVecWithNulError
impl Send for FromVecWithNulError
impl Sync for FromVecWithNulError
impl Unpin for FromVecWithNulError
impl UnwindSafe for FromVecWithNulError
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
source
impl<T> BorrowMut<T> for T where
T: ?Sized,
sourcefn borrow_mut(&mut self) -> &mut T
const: unstable · source
fn borrow_mut(&mut self) -> &mut T
const: unstable · sourceMutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
source
impl<T> ToOwned for T where
T: Clone,
sourcetype Owned = T
type Owned = T
The resulting type after obtaining ownership.
fn clone_into(&self, target: &mut T)
source
fn clone_into(&self, target: &mut T)
sourceUses borrowed data to replace owned data, usually by cloning. Read more