Skip to content

Commit 2df30a4

Browse files
author
Jorge Aparicio
committed
libserialize: use #[deriving(Copy)]
1 parent 1d25271 commit 2df30a4

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

src/libserialize/base64.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,25 @@ use std::fmt;
1919
use std::error;
2020

2121
/// Available encoding character sets
22+
#[deriving(Copy)]
2223
pub enum CharacterSet {
2324
/// The standard character set (uses `+` and `/`)
2425
Standard,
2526
/// The URL safe character set (uses `-` and `_`)
2627
UrlSafe
2728
}
2829

29-
impl Copy for CharacterSet {}
30-
3130
/// Available newline types
31+
#[deriving(Copy)]
3232
pub enum Newline {
3333
/// A linefeed (i.e. Unix-style newline)
3434
LF,
3535
/// A carriage return and a linefeed (i.e. Windows-style newline)
3636
CRLF
3737
}
3838

39-
impl Copy for Newline {}
40-
4139
/// Contains configuration parameters for `to_base64`.
40+
#[deriving(Copy)]
4241
pub struct Config {
4342
/// Character set to use
4443
pub char_set: CharacterSet,
@@ -50,8 +49,6 @@ pub struct Config {
5049
pub line_length: Option<uint>
5150
}
5251

53-
impl Copy for Config {}
54-
5552
/// Configuration for RFC 4648 standard base64 encoding
5653
pub static STANDARD: Config =
5754
Config {char_set: Standard, newline: Newline::CRLF, pad: true, line_length: None};
@@ -180,15 +177,14 @@ pub trait FromBase64 for Sized? {
180177
}
181178

182179
/// Errors that can occur when decoding a base64 encoded string
180+
#[deriving(Copy)]
183181
pub enum FromBase64Error {
184182
/// The input contained a character not part of the base64 format
185183
InvalidBase64Byte(u8, uint),
186184
/// The input had an invalid length
187185
InvalidBase64Length,
188186
}
189187

190-
impl Copy for FromBase64Error {}
191-
192188
impl fmt::Show for FromBase64Error {
193189
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
194190
match *self {

src/libserialize/hex.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,14 @@ pub trait FromHex for Sized? {
6161
}
6262

6363
/// Errors that can occur when decoding a hex encoded string
64+
#[deriving(Copy)]
6465
pub enum FromHexError {
6566
/// The input contained a character not part of the hex format
6667
InvalidHexCharacter(char, uint),
6768
/// The input had an invalid length
6869
InvalidHexLength,
6970
}
7071

71-
impl Copy for FromHexError {}
72-
7372
impl fmt::Show for FromHexError {
7473
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
7574
match *self {

src/libserialize/json.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ pub type Array = Vec<Json>;
226226
pub type Object = BTreeMap<string::String, Json>;
227227

228228
/// The errors that can arise while parsing a JSON stream.
229-
#[deriving(Clone, PartialEq)]
229+
#[deriving(Clone, Copy, PartialEq)]
230230
pub enum ErrorCode {
231231
InvalidSyntax,
232232
InvalidNumber,
@@ -247,17 +247,13 @@ pub enum ErrorCode {
247247
NotUtf8,
248248
}
249249

250-
impl Copy for ErrorCode {}
251-
252-
#[deriving(Clone, PartialEq, Show)]
250+
#[deriving(Clone, Copy, PartialEq, Show)]
253251
pub enum ParserError {
254252
/// msg, line, col
255253
SyntaxError(ErrorCode, uint, uint),
256254
IoError(io::IoErrorKind, &'static str),
257255
}
258256

259-
impl Copy for ParserError {}
260-
261257
// Builder and Parser have the same errors.
262258
pub type BuilderError = ParserError;
263259

0 commit comments

Comments
 (0)