Skip to content

Commit 4c62c76

Browse files
author
Jorge Aparicio
committed
libfmt_macros: use #[deriving(Copy)]
1 parent 30cefcb commit 4c62c76

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

src/libfmt_macros/lib.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use std::string;
3535

3636
/// A piece is a portion of the format string which represents the next part
3737
/// to emit. These are emitted as a stream by the `Parser` class.
38-
#[deriving(PartialEq)]
38+
#[deriving(Copy, PartialEq)]
3939
pub enum Piece<'a> {
4040
/// A literal string which should directly be emitted
4141
String(&'a str),
@@ -44,21 +44,17 @@ pub enum Piece<'a> {
4444
NextArgument(Argument<'a>),
4545
}
4646

47-
impl<'a> Copy for Piece<'a> {}
48-
4947
/// Representation of an argument specification.
50-
#[deriving(PartialEq)]
48+
#[deriving(Copy, PartialEq)]
5149
pub struct Argument<'a> {
5250
/// Where to find this argument
5351
pub position: Position<'a>,
5452
/// How to format the argument
5553
pub format: FormatSpec<'a>,
5654
}
5755

58-
impl<'a> Copy for Argument<'a> {}
59-
6056
/// Specification for the formatting of an argument in the format string.
61-
#[deriving(PartialEq)]
57+
#[deriving(Copy, PartialEq)]
6258
pub struct FormatSpec<'a> {
6359
/// Optionally specified character to fill alignment with
6460
pub fill: Option<char>,
@@ -76,10 +72,8 @@ pub struct FormatSpec<'a> {
7672
pub ty: &'a str
7773
}
7874

79-
impl<'a> Copy for FormatSpec<'a> {}
80-
8175
/// Enum describing where an argument for a format can be located.
82-
#[deriving(PartialEq)]
76+
#[deriving(Copy, PartialEq)]
8377
pub enum Position<'a> {
8478
/// The argument will be in the next position. This is the default.
8579
ArgumentNext,
@@ -89,10 +83,8 @@ pub enum Position<'a> {
8983
ArgumentNamed(&'a str),
9084
}
9185

92-
impl<'a> Copy for Position<'a> {}
93-
9486
/// Enum of alignments which are supported.
95-
#[deriving(PartialEq)]
87+
#[deriving(Copy, PartialEq)]
9688
pub enum Alignment {
9789
/// The value will be aligned to the left.
9890
AlignLeft,
@@ -104,11 +96,9 @@ pub enum Alignment {
10496
AlignUnknown,
10597
}
10698

107-
impl Copy for Alignment {}
108-
10999
/// Various flags which can be applied to format strings. The meaning of these
110100
/// flags is defined by the formatters themselves.
111-
#[deriving(PartialEq)]
101+
#[deriving(Copy, PartialEq)]
112102
pub enum Flag {
113103
/// A `+` will be used to denote positive numbers.
114104
FlagSignPlus,
@@ -122,11 +112,9 @@ pub enum Flag {
122112
FlagSignAwareZeroPad,
123113
}
124114

125-
impl Copy for Flag {}
126-
127115
/// A count is used for the precision and width parameters of an integer, and
128116
/// can reference either an argument or a literal integer.
129-
#[deriving(PartialEq)]
117+
#[deriving(Copy, PartialEq)]
130118
pub enum Count<'a> {
131119
/// The count is specified explicitly.
132120
CountIs(uint),
@@ -140,8 +128,6 @@ pub enum Count<'a> {
140128
CountImplied,
141129
}
142130

143-
impl<'a> Copy for Count<'a> {}
144-
145131
/// The parser structure for interpreting the input format string. This is
146132
/// modelled as an iterator over `Piece` structures to form a stream of tokens
147133
/// being output.

0 commit comments

Comments
 (0)