[−][src]Struct c_ffi::args::Args
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]
argc: isize,
argv: *const *const u8
) -> Result<Self, (usize, Utf8Error)>
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?
fn into_iter(self) -> Self::IntoIter
[src]
impl Copy for Args
[src]
impl Clone for Args
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,