Skip to content

Commit 3b4e9b8

Browse files
committed
Merge pull request http-rs#13 from Nercury/update-to-latest-master
Update to latest master.
2 parents 0cedc7a + 28d929c commit 3b4e9b8

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

src/lib.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
use nfa::NFA;
44
use nfa::CharacterClass;
55
use std::collections::BTreeMap;
6+
use std::cmp::Ordering;
7+
use std::ops::Index;
68

79
pub mod nfa;
810

9-
#[deriving(Clone)]
11+
#[derive(Clone)]
1012
struct Metadata {
1113
statics: int,
1214
dynamics: int,
@@ -23,19 +25,19 @@ impl Metadata {
2325
impl Ord for Metadata {
2426
fn cmp(&self, other: &Metadata) -> Ordering {
2527
if self.stars > other.stars {
26-
Less
28+
Ordering::Less
2729
} else if self.stars < other.stars {
28-
Greater
30+
Ordering::Greater
2931
} else if self.dynamics > other.dynamics {
30-
Less
32+
Ordering::Less
3133
} else if self.dynamics < other.dynamics {
32-
Greater
34+
Ordering::Greater
3335
} else if self.statics > other.statics {
34-
Less
36+
Ordering::Less
3537
} else if self.statics < other.statics {
36-
Greater
38+
Ordering::Greater
3739
} else {
38-
Equal
40+
Ordering::Equal
3941
}
4042
}
4143
}
@@ -54,7 +56,7 @@ impl PartialEq for Metadata {
5456

5557
impl Eq for Metadata {}
5658

57-
#[deriving(PartialEq, Clone, Show)]
59+
#[derive(PartialEq, Clone, Show)]
5860
pub struct Params {
5961
map: BTreeMap<String, String>
6062
}
@@ -93,7 +95,7 @@ impl<T> Match<T> {
9395
}
9496
}
9597

96-
#[deriving(Clone)]
98+
#[derive(Clone)]
9799
pub struct Router<T> {
98100
nfa: NFA<Metadata>,
99101
handlers: BTreeMap<uint, T>

src/nfa.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use std::u64;
33
use self::CharacterClass::{Ascii, ValidChars, InvalidChars};
44

55
#[cfg(test)] use test;
6-
#[cfg(test)] use std::collections::TreeSet;
6+
#[cfg(test)] use std::collections::BTreeSet;
77

8-
#[deriving(PartialEq, Eq, Clone)]
8+
#[derive(PartialEq, Eq, Clone)]
99
pub struct CharSet {
1010
low_mask: u64,
1111
high_mask: u64,
@@ -46,7 +46,7 @@ impl CharSet {
4646
}
4747
}
4848

49-
#[deriving(PartialEq, Eq, Clone)]
49+
#[derive(PartialEq, Eq, Clone)]
5050
pub enum CharacterClass {
5151
Ascii(u64, u64, bool),
5252
ValidChars(CharSet),
@@ -123,7 +123,7 @@ impl CharacterClass {
123123
}
124124
}
125125

126-
#[deriving(Clone)]
126+
#[derive(Clone)]
127127
struct Thread {
128128
state: uint,
129129
captures: Vec<(uint, uint)>,
@@ -151,7 +151,7 @@ impl Thread {
151151
}
152152
}
153153

154-
#[deriving(Clone)]
154+
#[derive(Clone)]
155155
pub struct State<T> {
156156
pub index: uint,
157157
pub chars: CharacterClass,
@@ -193,7 +193,7 @@ impl<'a> Match<'a> {
193193
}
194194
}
195195

196-
#[deriving(Clone)]
196+
#[derive(Clone)]
197197
pub struct NFA<T> {
198198
states: Vec<State<T>>,
199199
start_capture: Vec<bool>,
@@ -584,8 +584,8 @@ fn bench_hash_set(b: &mut test::Bencher) {
584584
}
585585

586586
#[bench]
587-
fn bench_tree_set(b: &mut test::Bencher) {
588-
let mut set = TreeSet::new();
587+
fn bench_btree_set(b: &mut test::Bencher) {
588+
let mut set = BTreeSet::new();
589589
set.insert('p');
590590
set.insert('n');
591591
set.insert('/');
@@ -606,4 +606,3 @@ fn valid(char: char) -> CharacterClass {
606606
fn invalid(char: char) -> CharacterClass {
607607
CharacterClass::invalid_char(char)
608608
}
609-

0 commit comments

Comments
 (0)