Struct NullString

Source
pub struct NullString { /* private fields */ }
Expand description

A wrapper for a 'static null-terminated string.

Sometimes used in favor of CStr or CString, as NullStrings can be made as compile-time constants.

Implementations§

Source§

impl NullString

Source

pub const fn new(s: &'static str) -> NullString

Creates a NullString from s or panics if s is not null-terminated.

§Panics

Panics if the string s does not end in the null character.

Source

pub const fn as_ptr(self) -> *const c_char

Returns a pointer to the beginning of the wrapped string.

Source

pub fn as_cstr(self) -> &'static CStr

Returns a &CStr pointing to the wrapped string.

Trait Implementations§

Source§

impl AsRef<CStr> for NullString

Source§

fn as_ref(&self) -> &CStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for NullString

Source§

fn clone(&self) -> NullString

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for NullString

Source§

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

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

impl From<&'static CStr> for NullString

Source§

fn from(cstr: &'static CStr) -> Self

Converts to this type from the input type.
Source§

impl From<NullString> for &'static CStr

Source§

fn from(nstr: NullString) -> Self

Converts to this type from the input type.
Source§

impl PrintfArgument for NullString

Source§

const IS_C_STRING: bool = true

Whether the type is a null-terminated string.
Source§

type CPrintfType = *const i8

The C type corresponding to Self that we should really send as an argument to a printf(3)-like function.
Source§

fn as_c_val(self) -> *const c_char

Converts self to a value suitable for sending to printf(3).
Source§

const IS_CHAR: bool = false

Whether the type is consistent with C’s char.
Source§

const IS_SHORT: bool = false

Whether the type is consistent with C’s short int.
Source§

const IS_INT: bool = false

Whether the type is consistent with C’s int.
Source§

const IS_LONG: bool = false

Whether the type is consistent with C’s long int.
Source§

const IS_LONG_LONG: bool = false

Whether the type is consistent with C’s long long int.
Source§

const IS_SIZE: bool = false

Available on crate feature libc only.
Whether the type is consistent with C’s size_t.
Source§

const IS_MAX: bool = false

Available on crate feature libc only.
Whether the type is consistent with C’s intmax_t.
Source§

const IS_PTRDIFF: bool = false

Available on crate feature libc only.
Whether the type is consistent with C’s ptrdiff_t.
Source§

const IS_SIGNED: bool = false

Whether the type is a signed integer type, as opposed to unsigned.
Source§

const IS_FLOAT: bool = false

Whether the type is floating-point.
Source§

const IS_POINTER: bool = false

Whether the type is a pointer.
Source§

impl Copy for NullString

Source§

impl Send for NullString

Source§

impl Sync for NullString

Auto Trait Implementations§

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> PrintfArgs for T
where T: PrintfArgument,

Source§

type AsList = (T, ())

The PrintfArgsList equivalent to Self.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.