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 A
pub 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) -> usize
Return 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], &Nul<A>)
[src]
pub fn split_at(&self, i: usize) -> (&[A], &Nul<A>)
pub fn split_at_mut(&mut self, i: usize) -> (&mut [A], &mut Nul<A>)
[src]
pub fn split_at_mut(&mut self, i: usize) -> (&mut [A], &mut Nul<A>)
pub fn try_split_at(&self, i: usize) -> Option<(&[A], &Nul<A>)>
[src]
pub fn try_split_at(&self, i: usize) -> Option<(&[A], &Nul<A>)>
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 Nul<A>)>
[src]
pub fn try_split_at_mut(&mut self, i: usize) -> Option<(&mut [A], &mut Nul<A>)>
Split array at given position, mutably; return None
if index out of bounds.
Trait Implementations
impl<A> Eq for Nul<A> where
A: Eq,
[src]
impl<A> Eq for Nul<A> where
A: Eq,
impl<A> AsRef<Nul<A>> for Nul<A>
[src]
impl<A> AsRef<Nul<A>> for Nul<A>
impl<A> Ord for Nul<A> where
A: Ord,
[src]
impl<A> Ord for Nul<A> where
A: Ord,
fn cmp(&self, other: &Nul<A>) -> Ordering
[src]
fn cmp(&self, other: &Nul<A>) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<A> Debug for Nul<A> where
A: Debug,
[src]
impl<A> Debug for Nul<A> where
A: Debug,
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. 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 Display for Nul<char>
[src]
impl Display for Nul<char>
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl<A> PartialOrd<Nul<A>> for Nul<A> where
A: PartialOrd<A>,
[src]
impl<A> PartialOrd<Nul<A>> for Nul<A> where
A: PartialOrd<A>,
fn partial_cmp(&self, other: &Nul<A>) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Nul<A>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
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) -> &<Nul<A> as Index<I>>::Output
[src]
fn index(&self, i: I) -> &<Nul<A> as Index<I>>::Output
Performs 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 <Nul<A> as Index<I>>::Output
[src]
fn index_mut(&mut self, i: I) -> &mut <Nul<A> as Index<I>>::Output
Performs the mutable indexing (container[index]
) operation.
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<'a, A> From<Iter<'a, A>> for &'a Nul<A>
[src]
impl<'a, A> From<Iter<'a, A>> for &'a Nul<A>
impl<A> PartialEq<Nul<A>> for Nul<A> where
A: PartialEq<A>,
[src]
impl<A> PartialEq<Nul<A>> for Nul<A> where
A: PartialEq<A>,
fn eq(&self, other: &Nul<A>) -> bool
[src]
fn eq(&self, other: &Nul<A>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
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> IntoIterator for &'a Nul<A>
[src]
impl<'a, A> IntoIterator for &'a Nul<A>