Struct null_terminated::Nul [−][src]
#[repr(C)]pub struct Nul<A>(_, _);
Expand description
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 ::std::convert::TryFrom<_>>::try_from(path) .map(|path| unsafe { c_f(path.as_ptr()) }) }
Implementations
impl<A> Nul<A>
[src]
impl<A> Nul<A>
[src]pub fn as_mut_ptr(&mut self) -> *mut A
[src]
pub fn as_mut_ptr(&mut self) -> *mut A
[src]Return a mutable pointer to the start of the array.
pub const unsafe fn new_unchecked(p: *const A) -> &'static Self
[src]
pub const unsafe fn new_unchecked(p: *const A) -> &'static Self
[src]Create a reference to a null-terminated array, given a pointer to its start.
The caller must make sure the argument does, in fact, point to a null-terminated array, and the returned reference not live longer than the array it refers to. These requirements are not checked.
pub unsafe fn new_unchecked_mut(p: *mut A) -> &'static mut Self
[src]
pub unsafe fn new_unchecked_mut(p: *mut A) -> &'static mut Self
[src]Create a mutable reference to a null-terminated array, given a pointer to its start.
The caller must make sure the argument does, in fact, point to a null-terminated array, and the returned reference not live longer than the array it refers to. These requirements are not checked.
pub fn get_mut(&mut self, i: usize) -> Option<&mut A>
[src]
pub fn get_mut(&mut self, i: usize) -> Option<&mut A>
[src]Get element at given position, mutably. O(n)
to check bounds
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)
[src]pub fn try_split_at(&self, i: usize) -> Option<(&[A], &Self)>
[src]
pub fn try_split_at(&self, i: usize) -> Option<(&[A], &Self)>
[src]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)>
[src]Split array at given position, mutably; return None
if index out of bounds.
Trait Implementations
impl<'a, A> IntoIterator for &'a Nul<A>
[src]
impl<'a, A> IntoIterator for &'a Nul<A>
[src]type Item = &'a A
type Item = &'a A
The type of the elements being iterated over.
impl<'a, A> IntoIterator for &'a mut Nul<A>
[src]
impl<'a, A> IntoIterator for &'a mut Nul<A>
[src]type Item = &'a mut A
type Item = &'a mut A
The type of the elements being iterated over.
impl<A: Ord> Ord for Nul<A>
[src]
impl<A: Ord> Ord for Nul<A>
[src]impl<A: PartialOrd> PartialOrd<Nul<A>> for Nul<A>
[src]
impl<A: PartialOrd> PartialOrd<Nul<A>> for Nul<A>
[src]fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<A: Eq> Eq for Nul<A>
[src]
Auto Trait Implementations
impl<A> Send for Nul<A> where
A: Send,
A: Send,
impl<A> !Sized for Nul<A>
impl<A> Sync for Nul<A> where
A: Sync,
A: Sync,