Skip to content

Commit 8986e13

Browse files
committed
rust upgrade
1 parent 7898f1c commit 8986e13

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

src/lib.rs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
//!
1010
//! ```rust
1111
//! # use std::str::FromStr;
12-
//! use mime::{Mime, Text, Plain, Charset, Utf8};
12+
//! # use mime::Mime;
13+
//! # use mime::TopLevel::Text;
14+
//! # use mime::SubLevel::Plain;
15+
//! # use mime::Attr::Charset;
16+
//! # use mime::Value::Utf8;
1317
//! let mime: Mime = FromStr::from_str("text/plain;charset=utf-8").unwrap();
1418
//! assert_eq!(mime, Mime(Text, Plain, vec![(Charset, Utf8)]));
1519
//! ```
1620
17-
#![license = "MIT"]
18-
#![doc(html_root_url = "http://seanmonstar.github.io/mime.rs")]
21+
#![doc(html_root_url = "http://hyperium.github.io/mime.rs")]
1922
#![experimental]
2023
#![feature(macro_rules, phase)]
2124

@@ -26,7 +29,6 @@ extern crate log;
2629
extern crate test;
2730

2831
use std::ascii::AsciiExt;
29-
use std::cmp::Equiv;
3032
use std::fmt;
3133
use std::str::FromStr;
3234
use std::iter::Enumerate;
@@ -38,7 +40,7 @@ macro_rules! inspect(
3840
debug!("inspect {}: {}", $s, t);
3941
t
4042
})
41-
)
43+
);
4244

4345
/// Mime, or Media Type. Encapsulates common registers types.
4446
///
@@ -54,27 +56,37 @@ macro_rules! inspect(
5456
///
5557
/// ```rust
5658
/// use std::str::from_str;
57-
/// use mime::{Mime, Application, Json};
59+
/// use mime::{Mime, TopLevel, SubLevel};
5860
///
5961
/// let mime: mime::Mime = from_str("application/json").unwrap();
6062
///
6163
/// match mime {
62-
/// Mime(Application, Json, _) => println!("matched json!"),
64+
/// Mime(TopLevel::Application, SubLevel::Json, _) => println!("matched json!"),
6365
/// _ => ()
6466
/// }
6567
/// ```
6668
#[deriving(Clone, PartialEq)]
6769
pub struct Mime(pub TopLevel, pub SubLevel, pub Vec<Param>);
6870

69-
macro_rules! enoom (
71+
macro_rules! enoom {
7072
(pub enum $en:ident; $ext:ident; $($ty:ident, $text:expr;)*) => (
7173

72-
#[deriving(Clone, PartialEq)]
74+
#[deriving(Clone)]
7375
pub enum $en {
7476
$($ty),*,
7577
$ext(String)
7678
}
7779

80+
impl PartialEq for $en {
81+
fn eq(&self, other: &$en) -> bool {
82+
match (self, other) {
83+
$( (&$en::$ty, &$en::$ty) => true ),*,
84+
(&$en::$ext(ref a), &$en::$ext(ref b)) => a == b,
85+
_ => self.to_string() == other.to_string()
86+
}
87+
}
88+
}
89+
7890
impl fmt::Show for $en {
7991
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
8092
match *self {
@@ -93,7 +105,7 @@ macro_rules! enoom (
93105
}
94106
}
95107
)
96-
)
108+
}
97109

98110
enoom! {
99111
pub enum TopLevel;
@@ -150,14 +162,6 @@ enoom! {
150162

151163
pub type Param = (Attr, Value);
152164

153-
impl Equiv<Mime> for Mime {
154-
fn equiv(&self, other: &Mime) -> bool {
155-
//im so sorry
156-
//TODO: be less sorry. dont to_string()
157-
self.to_string() == other.to_string()
158-
}
159-
}
160-
161165
impl fmt::Show for Mime {
162166
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
163167
let Mime(ref top, ref sub, ref params) = *self;

0 commit comments

Comments
 (0)