Trait Arg

Source
pub trait Arg: Sized + AsRef<OsStr> {
    // Required method
    fn parse<T: ParseArg>(self) -> Result<T, <T as ParseArg>::Error>;
}
Expand description

A type that can be parsed.

Usually &OsStr or OsString. It’s used to automatically pick the right method of ParseArg trait.

Required Methods§

Source

fn parse<T: ParseArg>(self) -> Result<T, <T as ParseArg>::Error>

Parses the argument from self using appropriate method.

In case self is OsString or can be converted to it at no cost ParseArg::parse_owned_arg() is used. Otherwise ParseArg::parse_arg() is used.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Arg for String

Using this with std::env::args() is not a good practice, but it may be useful for testing.

Source§

fn parse<T: ParseArg>(self) -> Result<T, <T as ParseArg>::Error>

Source§

impl Arg for OsString

Source§

fn parse<T: ParseArg>(self) -> Result<T, <T as ParseArg>::Error>

Source§

impl<'a> Arg for &'a str

Using this with std::env::args() is not a good practice, but it may be useful for testing.

Source§

fn parse<T: ParseArg>(self) -> Result<T, <T as ParseArg>::Error>

Source§

impl<'a> Arg for &'a OsStr

Source§

fn parse<T: ParseArg>(self) -> Result<T, <T as ParseArg>::Error>

Source§

impl<'a, U: 'a + Arg + Copy> Arg for &'a U

Source§

fn parse<T: ParseArg>(self) -> Result<T, <T as ParseArg>::Error>

Implementors§