Struct null_terminated::Nul [−][src]
pub struct Nul<A>(_, _);
Generic unsized null-terminated array
&Nul<A> is a thin pointer, so it can be readily used with FFI.
Examples
One can safely take views of null-terminated slices with TryFrom::try_from:
extern "C" { fn c_f(path: *const u8) -> i32; } fn f(path: &[u8]) -> Result<i32, ()> { <&Nul<u8> as ::fallible::TryFrom<_>>::try_from(path) .map(|path| unsafe { c_f(path.as_ptr()) }) }
Methods
impl<A> Nul<A>[src]
impl<A> Nul<A>pub const fn as_ptr(&self) -> *const A[src]
pub const fn as_ptr(&self) -> *const Apub fn as_mut_ptr(&mut self) -> *mut A[src]
pub fn as_mut_ptr(&mut self) -> *mut AⓘImportant traits for Iter<'a, A>pub const fn iter(&self) -> Iter<A>[src]
pub const fn iter(&self) -> Iter<A>Iterate over array elements.
ⓘImportant traits for IterMut<'a, A>pub fn iter_mut(&mut self) -> IterMut<A>[src]
pub fn iter_mut(&mut self) -> IterMut<A>Iterate over array elements, mutably.
pub const unsafe fn new_unchecked(p: *const A) -> &'static Nul<A>[src]
pub const unsafe fn new_unchecked(p: *const A) -> &'static Nul<A>pub unsafe fn new_unchecked_mut(p: *mut A) -> &'static mut Nul<A>[src]
pub unsafe fn new_unchecked_mut(p: *mut A) -> &'static mut Nul<A>pub fn len(&self) -> usize[src]
pub fn len(&self) -> usizeReturn array length. O(n)
pub fn get(&self, i: usize) -> Option<&A>[src]
pub fn get(&self, i: usize) -> Option<&A>Get element at given position. O(n) to check bounds
pub fn get_mut(&mut self, i: usize) -> Option<&mut A>[src]
pub fn get_mut(&mut self, i: usize) -> Option<&mut A>Get element at given position, mutably. O(n) to check bounds
pub fn split_at(&self, i: usize) -> (&[A], &Self)[src]
pub fn split_at(&self, i: usize) -> (&[A], &Self)pub fn split_at_mut(&mut self, i: usize) -> (&mut [A], &mut Self)[src]
pub fn split_at_mut(&mut self, i: usize) -> (&mut [A], &mut Self)pub fn try_split_at(&self, i: usize) -> Option<(&[A], &Self)>[src]
pub fn try_split_at(&self, i: usize) -> Option<(&[A], &Self)>Split array at given position; return None if index out of bounds.
pub fn try_split_at_mut(&mut self, i: usize) -> Option<(&mut [A], &mut Self)>[src]
pub fn try_split_at_mut(&mut self, i: usize) -> Option<(&mut [A], &mut Self)>Split array at given position, mutably; return None if index out of bounds.
Trait Implementations
impl<A, I> Index<I> for Nul<A> where
[A]: Index<I>, [src]
impl<A, I> Index<I> for Nul<A> where
[A]: Index<I>, type Output = <[A] as Index<I>>::Output
The returned type after indexing.
fn index(&self, i: I) -> &Self::Output[src]
fn index(&self, i: I) -> &Self::OutputPerforms the indexing (container[index]) operation.
impl<A, I> IndexMut<I> for Nul<A> where
[A]: IndexMut<I>, [src]
impl<A, I> IndexMut<I> for Nul<A> where
[A]: IndexMut<I>, fn index_mut(&mut self, i: I) -> &mut Self::Output[src]
fn index_mut(&mut self, i: I) -> &mut Self::OutputPerforms the mutable indexing (container[index]) operation.
impl<A: Debug> Debug for Nul<A>[src]
impl<A: Debug> Debug for Nul<A>fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<A: PartialEq> PartialEq for Nul<A>[src]
impl<A: PartialEq> PartialEq for Nul<A>fn eq(&self, other: &Self) -> bool[src]
fn eq(&self, other: &Self) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl<A: Eq> Eq for Nul<A>[src]
impl<A: Eq> Eq for Nul<A>impl<A: PartialOrd> PartialOrd for Nul<A>[src]
impl<A: PartialOrd> PartialOrd for Nul<A>fn partial_cmp(&self, other: &Self) -> Option<Ordering>[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
fn lt(&self, other: &Rhs) -> boolThis method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Rhs) -> bool1.0.0[src]
fn le(&self, other: &Rhs) -> boolThis method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
fn gt(&self, other: &Rhs) -> boolThis method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
fn ge(&self, other: &Rhs) -> boolThis method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl<A: Ord> Ord for Nul<A>[src]
impl<A: Ord> Ord for Nul<A>fn cmp(&self, other: &Self) -> Ordering[src]
fn cmp(&self, other: &Self) -> OrderingThis method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
fn max(self, other: Self) -> SelfCompares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> SelfCompares and returns the minimum of two values. Read more
impl<'a, A> TryFrom<&'a [A]> for &'a Nul<A>[src]
impl<'a, A> TryFrom<&'a [A]> for &'a Nul<A>impl<'a, A> TryFrom<&'a mut [A]> for &'a mut Nul<A>[src]
impl<'a, A> TryFrom<&'a mut [A]> for &'a mut Nul<A>impl<'a, A> IntoIterator for &'a Nul<A>[src]
impl<'a, A> IntoIterator for &'a Nul<A>type Item = &'a A
The type of the elements being iterated over.
type IntoIter = Iter<'a, A>
Which kind of iterator are we turning this into?
ⓘImportant traits for Iter<'a, A>fn into_iter(self) -> Iter<'a, A>[src]
fn into_iter(self) -> Iter<'a, A>Creates an iterator from a value. Read more
impl<'a, A> IntoIterator for &'a mut Nul<A>[src]
impl<'a, A> IntoIterator for &'a mut Nul<A>type Item = &'a mut A
The type of the elements being iterated over.
type IntoIter = IterMut<'a, A>
Which kind of iterator are we turning this into?
ⓘImportant traits for IterMut<'a, A>fn into_iter(self) -> IterMut<'a, A>[src]
fn into_iter(self) -> IterMut<'a, A>Creates an iterator from a value. Read more
impl<'a, A> From<Iter<'a, A>> for &'a Nul<A>[src]
impl<'a, A> From<Iter<'a, A>> for &'a Nul<A>impl<'a, A> From<IterMut<'a, A>> for &'a mut Nul<A>[src]
impl<'a, A> From<IterMut<'a, A>> for &'a mut Nul<A>impl Display for Nul<char>[src]
impl Display for Nul<char>fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<A> AsRef<Nul<A>> for Nul<A>[src]
impl<A> AsRef<Nul<A>> for Nul<A>