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

Return a pointer to the start of the array.

Return a mutable pointer to the start of the array.

Iterate over array elements.

Iterate over array elements, mutably.

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.

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.

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

Performs the conversion.

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

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

Restrict a value to a certain interval. Read more

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

This method tests for !=.

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.