Struct NulError
pub struct NulError(pub(in ::ffi::c_str) usize, pub(in ::ffi::c_str) Vec<u8>);
An error indicating that an interior nul byte was found.
While Rust strings may contain nul bytes in the middle, C strings can't, as that byte would effectively truncate the string.
This error is created by the [new]CString::new method on
CString. See its documentation for more.
Examples
use ;
let _: NulError = new.unwrap_err;
Fields
0: usize1: Vec<u8>
Implementations
impl NulError
fn nul_position(&self) -> usizeReturns the position of the nul byte in the slice that caused
CString::newto fail.Examples
use CString; let nul_error = new.unwrap_err; assert_eq!; let nul_error = new.unwrap_err; assert_eq!;fn into_vec(self) -> Vec<u8>Consumes this error, returning the underlying vector of bytes which generated the error in the first place.
Examples
use CString; let nul_error = new.unwrap_err; assert_eq!;
Trait Implementations
impl Clone for NulError
fn clone(&self) -> NulError
impl Debug for NulError
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Display for NulError
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for NulError
fn assert_fields_are_eq(&self)
impl Error for NulError
impl PartialEq for NulError
fn eq(&self, other: &NulError) -> bool
impl StructuralPartialEq for NulError
Auto Trait Implementations
impl Freeze for NulError
impl RefUnwindSafe for NulError
impl Send for NulError
impl Sync for NulError
impl Unpin for NulError
impl UnsafeUnpin for NulError
impl UnwindSafe for NulError
Blanket Implementations
impl<T> Any for NulError
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for NulError
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for NulError
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for NulError
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for NulError
fn from(t: T) -> TReturns the argument unchanged.
impl<T> SizeHint for NulError
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for NulError
impl<T> ToOwned for NulError
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> ToString for NulError
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for NulError
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 NulError
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 NulError
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>