pub struct Config { /* private fields */ }
Expand description

Helper for command-line mode

Examples

use numbers_into_words::Config;
use std::env;

/* Essentially the entire main function for the command-line program */
let args: Vec<String> = env::args().collect();
let config = Config::parse(args);
println!("{}", config.process());
use numbers_into_words::Config;

let args: Vec<String> = vec!["program_name".to_string(), "42".to_string()];
assert_eq!(
    Config::parse(args).process(),
    String::from("42: forty-two"));

Implementations§

source§

impl Config

source

pub fn parse(args: Vec<String>) -> Self

Parses the command-line arguments and encodes them in a Config

source

pub fn process(&self) -> String

Returns the program output appropriate for the command-line arguments used to encode the Config

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.