Skip to content

Commit

Permalink
getopts: derive Eq for types.
Browse files Browse the repository at this point in the history
  • Loading branch information
huonw committed Jun 14, 2014
1 parent 0642cbb commit 09eb95f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/libgetopts/lib.rs
Expand Up @@ -100,7 +100,7 @@ use std::result;
use std::string::String;

/// Name of an option. Either a string or a single char.
#[deriving(Clone, PartialEq)]
#[deriving(Clone, PartialEq, Eq)]
pub enum Name {
/// A string representing the long name of an option.
/// For example: "help"
Expand All @@ -111,7 +111,7 @@ pub enum Name {
}

/// Describes whether an option has an argument.
#[deriving(Clone, PartialEq)]
#[deriving(Clone, PartialEq, Eq)]
pub enum HasArg {
/// The option requires an argument.
Yes,
Expand All @@ -122,7 +122,7 @@ pub enum HasArg {
}

/// Describes how often an option may occur.
#[deriving(Clone, PartialEq)]
#[deriving(Clone, PartialEq, Eq)]
pub enum Occur {
/// The option occurs once.
Req,
Expand All @@ -133,7 +133,7 @@ pub enum Occur {
}

/// A description of a possible option.
#[deriving(Clone, PartialEq)]
#[deriving(Clone, PartialEq, Eq)]
pub struct Opt {
/// Name of the option
pub name: Name,
Expand All @@ -142,12 +142,12 @@ pub struct Opt {
/// How often it can occur
pub occur: Occur,
/// Which options it aliases
pub aliases: Vec<Opt> ,
pub aliases: Vec<Opt>,
}

/// One group of options, e.g., both -h and --help, along with
/// their shared description and properties.
#[deriving(Clone, PartialEq)]
#[deriving(Clone, PartialEq, Eq)]
pub struct OptGroup {
/// Short Name of the `OptGroup`
pub short_name: String,
Expand All @@ -164,28 +164,28 @@ pub struct OptGroup {
}

/// Describes whether an option is given at all or has a value.
#[deriving(Clone, PartialEq)]
#[deriving(Clone, PartialEq, Eq)]
enum Optval {
Val(String),
Given,
}

/// The result of checking command line arguments. Contains a vector
/// of matches and a vector of free strings.
#[deriving(Clone, PartialEq)]
#[deriving(Clone, PartialEq, Eq)]
pub struct Matches {
/// Options that matched
opts: Vec<Opt> ,
opts: Vec<Opt>,
/// Values of the Options that matched
vals: Vec<Vec<Optval> > ,
vals: Vec<Vec<Optval>>,
/// Free string fragments
pub free: Vec<String>,
}

/// The type returned when the command line does not conform to the
/// expected format. Use the `Show` implementation to output detailed
/// information.
#[deriving(Clone, PartialEq)]
#[deriving(Clone, PartialEq, Eq)]
pub enum Fail_ {
/// The option requires an argument but none was passed.
ArgumentMissing(String),
Expand All @@ -200,7 +200,7 @@ pub enum Fail_ {
}

/// The type of failure that occurred.
#[deriving(PartialEq)]
#[deriving(PartialEq, Eq)]
#[allow(missing_doc)]
pub enum FailType {
ArgumentMissing_,
Expand Down

5 comments on commit 09eb95f

@bors
Copy link
Contributor

@bors bors commented on 09eb95f Jun 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at huonw@09eb95f

@bors
Copy link
Contributor

@bors bors commented on 09eb95f Jun 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging huonw/rust/getoptsfail = 09eb95f into auto

@bors
Copy link
Contributor

@bors bors commented on 09eb95f Jun 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huonw/rust/getoptsfail = 09eb95f merged ok, testing candidate = d64f18c

@bors
Copy link
Contributor

@bors bors commented on 09eb95f Jun 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = d64f18c

Please sign in to comment.