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]

Important traits for Iter<'a, A>

Iterate over array elements.

Important traits for IterMut<'a, A>

Iterate over array elements, mutably.

Return array length. O(n)

Get element at given position. O(n) to check bounds

Get element at given position, mutably. O(n) to check bounds

Split array at given position.

Panics

Panics if index out of bounds.

Split array at given position, mutably.

Panics

Panics if index out of bounds.

Split array at given position; return None if index out of bounds.

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> AsRef<Nul<A>> for Nul<A>
[src]

Performs the conversion.

impl<A> Ord for Nul<A> where
    A: Ord
[src]

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl<A> Debug for Nul<A> where
    A: Debug
[src]

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 mut [A]> for &'a mut Nul<A>
[src]

impl Display for Nul<char>
[src]

Formats the value using the given formatter. Read more

impl<A> PartialOrd<Nul<A>> for Nul<A> where
    A: PartialOrd<A>, 
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

The returned type after indexing.

Performs the indexing (container[index]) operation.

impl<A, I> IndexMut<I> for Nul<A> where
    [A]: IndexMut<I>, 
[src]

Performs the mutable indexing (container[index]) operation.

impl<'a, A> From<IterMut<'a, A>> for &'a mut Nul<A>
[src]

Performs the conversion.

impl<'a, A> From<Iter<'a, A>> for &'a Nul<A>
[src]

Performs the conversion.

impl<A> PartialEq<Nul<A>> for Nul<A> where
    A: PartialEq<A>, 
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<'a, A> IntoIterator for &'a mut Nul<A>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Important traits for IterMut<'a, A>

Creates an iterator from a value. Read more

impl<'a, A> IntoIterator for &'a Nul<A>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Important traits for Iter<'a, A>

Creates an iterator from a value. Read more

Auto Trait Implementations

impl<A> Send for Nul<A> where
    A: Send

impl<A> Sync for Nul<A> where
    A: Sync