[][src]Struct c_ffi::args::Args

pub struct Args { /* fields omitted */ }

Wrapper over C-style arguments

Example:

On most targets you can supply own C-style main function.

One of the benefits is that it is no longer necessary to rely on allocating std::env::Args

#![no_main]

#[no_mangle]
unsafe extern "C" fn main(argc: isize, argv: *const *const u8) -> isize {
    let args = c_ffi::Args::new(argc, argv).expect("To get function arguments");

    0
}

Methods

impl Args[src]

pub unsafe fn new(
    argc: isize,
    argv: *const *const u8
) -> Result<Self, (usize, Utf8Error)>
[src]

Creates new instance, but verifies that each string inside are UTF-8.

On error returns pair: (string index, Utf8Error)

The function is safe as long as you pass C style main function arguments.

pub unsafe fn new_unchecked(argc: isize, argv: *const *const u8) -> Self[src]

Unchecked version of Args::new

Do it on your own risk

pub fn as_slice(&self) -> &[*const u8][src]

Returns slice of raw C strings

pub unsafe fn get_str_by_index(&self, index: usize) -> &str[src]

Retrieves string by index.

No checks, 100% unsafe.

Trait Implementations

impl<'a> IntoIterator for &'a Args[src]

type Item = &'a str

The type of the elements being iterated over.

type IntoIter = IntoIter<'a>

Which kind of iterator are we turning this into?

impl Copy for Args[src]

impl Clone for Args[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Unpin for Args

impl !Sync for Args

impl !Send for Args

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]