[−][src]Struct easy_flag::FlagSet
Represents a set of defined flags.
Methods
impl<'a> FlagSet<'a>
[src]
pub fn new(name: &str) -> Self
[src]
Constructs a new FlagSet
instance. The name
will be added to the usage information.
Examples
let set = FlagSet::new("my set")
pub fn add(self, name: &'a str, var: &'a mut dyn Any, help: &'a str) -> Self
[src]
Adds a new flag to the FlagSet
The function itself determines the type of flag.
The standard types are supported: bool
, f32
, f64
, i8
, i16
, i32
, i128
,
isize
, u8
, u16
, u32
, u128
, usize
, String
.
WARNING: Unsupported type will cause panic.
Examples
let mut f = String::from("default value"); FlagSet::new("my set").add("-f, --flag", &mut f, "flag `example`")
pub fn parse(&mut self, args: &[String]) -> Result<(), String>
[src]
Parsing args.
Examples
let mut f = String::from("default value"); let args: Vec<String> = std::env::args().collect(); FlagSet::new(&args[0]) .add("-f, --flag", &mut f, "flag `example`") .parse(&args[1..]) .unwrap()
pub fn name(&self) -> &str
[src]
Gets flag set name.
pub fn usage(&self) -> String
[src]
Formats a usage message with set name.
pub fn defaults(&self) -> String
[src]
Formats a flag list message.
Trait Implementations
Auto Trait Implementations
impl<'a> Send for FlagSet<'a>
impl<'a> Sync for FlagSet<'a>
impl<'a> Unpin for FlagSet<'a>
impl<'a> !UnwindSafe for FlagSet<'a>
impl<'a> RefUnwindSafe for FlagSet<'a>
Blanket Implementations
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> 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> 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,