From c407785ac0b535dc98e9bf2d9c595111cfff31cc Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 14 Dec 2014 22:37:29 -0500 Subject: [PATCH] libgetopts: use `#[deriving(Copy)]` --- src/libgetopts/lib.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index 38729eece5ab..b45d0c9b01ec 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -118,7 +118,7 @@ pub enum Name { } /// Describes whether an option has an argument. -#[deriving(Clone, PartialEq, Eq)] +#[deriving(Clone, Copy, PartialEq, Eq)] pub enum HasArg { /// The option requires an argument. Yes, @@ -128,10 +128,8 @@ pub enum HasArg { Maybe, } -impl Copy for HasArg {} - /// Describes how often an option may occur. -#[deriving(Clone, PartialEq, Eq)] +#[deriving(Clone, Copy, PartialEq, Eq)] pub enum Occur { /// The option occurs once. Req, @@ -141,8 +139,6 @@ pub enum Occur { Multi, } -impl Copy for Occur {} - /// A description of a possible option. #[deriving(Clone, PartialEq, Eq)] pub struct Opt { @@ -211,7 +207,7 @@ pub enum Fail { } /// The type of failure that occurred. -#[deriving(PartialEq, Eq)] +#[deriving(Copy, PartialEq, Eq)] #[allow(missing_docs)] pub enum FailType { ArgumentMissing_, @@ -221,8 +217,6 @@ pub enum FailType { UnexpectedArgument_, } -impl Copy for FailType {} - /// The result of parsing a command line with a set of options. pub type Result = result::Result; @@ -839,22 +833,22 @@ pub fn short_usage(program_name: &str, opts: &[OptGroup]) -> String { line } +#[deriving(Copy)] enum SplitWithinState { A, // leading whitespace, initial state B, // words C, // internal and trailing whitespace } -impl Copy for SplitWithinState {} +#[deriving(Copy)] enum Whitespace { Ws, // current char is whitespace Cr // current char is not whitespace } -impl Copy for Whitespace {} +#[deriving(Copy)] enum LengthLimit { UnderLim, // current char makes current substring still fit in limit OverLim // current char makes current substring no longer fit in limit } -impl Copy for LengthLimit {} /// Splits a string into substrings with possibly internal whitespace,