Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
CreepySkeleton committed Oct 8, 2020
1 parent 98d5d80 commit 1cd8405
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,12 +1076,12 @@ pub trait StructOpt {
/// Returns [`clap::App`] corresponding to the struct.
fn clap<'a, 'b>() -> clap::App<'a, 'b>;

/// Builds the struct from [`clap::ArgMatches`]. It's guaranteed to succeed
/// if `matches` originates from an `App` generated by [`StructOpt::clap`] called on
/// Builds the struct from [`clap::ArgMatches`]. It's guaranteed to succeed
/// if `matches` originates from an `App` generated by [`StructOpt::clap`] called on
/// the same type, otherwise it must panic.
fn from_clap(matches: &clap::ArgMatches<'_>) -> Self;

/// Builds the struct from the command line arguments ([`std::env::args_os`]).
/// Builds the struct from the command line arguments ([`std::env::args_os`]).
/// Calls [`clap::Error::exit`] on failure, printing the error message and aborting the program.
fn from_args() -> Self
where
Expand All @@ -1090,14 +1090,16 @@ pub trait StructOpt {
Self::from_clap(&Self::clap().get_matches())
}

/// Builds the struct from the command line arguments ([`std::env::args_os`]).
/// Unlike [`StructOpt::from_args`], returns [`clap::Error`] on failure instead of aborting the program,
/// Builds the struct from the command line arguments ([`std::env::args_os`]).
/// Unlike [`StructOpt::from_args`], returns [`clap::Error`] on failure instead of aborting the program,
/// so calling [`.exit`][clap::Error::exit] is up to you.
fn from_args_safe() -> Result<Self, clap::Error>
where
Self: Sized,
{
Self::clap().get_matches_safe().map(|matches| Self::from_clap(&matches))
Self::clap()
.get_matches_safe()
.map(|matches| Self::from_clap(&matches))
}

/// Gets the struct from any iterator such as a `Vec` of your making.
Expand Down

0 comments on commit 1cd8405

Please sign in to comment.