Skip to content

Commit 4a311dd

Browse files
committed
Update to Rust 0.8-pre~54c8c23
1 parent d9d4f7d commit 4a311dd

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

ast.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5+
use std::str::ToStr;
6+
57

68
#[deriving(Eq)]
79
pub struct NumericValue {
@@ -108,3 +110,7 @@ pub enum ErrorReason {
108110
ErrInvalidBangImportantSyntax,
109111
// This is meant to be extended
110112
}
113+
114+
impl ToStr for ErrorReason {
115+
fn to_str(&self) -> ~str { fmt!("%?", self) }
116+
}

cssparser.rc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static CFG_TEST: bool = true;
2828
pub fn eq_ascii_lower(string: &str, reference: &str) -> bool {
2929
#[inline]
3030
fn eq(string: &str, reference: &str) -> bool {
31-
for std::uint::range(0, string.len()) |i| {
31+
for i in range(0, string.len()) {
3232
if ASCII_LOWER_MAP[string[i]] != reference[i] {
3333
return false
3434
}
@@ -47,7 +47,7 @@ pub fn eq_ascii_lower(string: &str, reference: &str) -> bool {
4747
/// A-Z is replaced by a-z, non-ASCII letters are unchanged.
4848
pub fn to_ascii_lower(string: &str) -> ~str {
4949
let mut lower = string.to_owned();
50-
for std::uint::range(0, lower.len()) |i| {
50+
for i in range(0, lower.len()) {
5151
lower[i] = ASCII_LOWER_MAP[lower[i]];
5252
}
5353
lower
@@ -62,7 +62,7 @@ fn test_ascii_lower() {
6262
assert!(eq_ascii_lower("HİKß", "hİKß"));
6363
assert!(to_ascii_lower("HİKß") == ~"hİKß");
6464

65-
for std::uint::range(0, 128) |i| {
65+
for i in range(0, 128) {
6666
let c = i as char;
6767
let lower = if 'A' <= c && c <= 'Z' { c + 'a' - 'A' } else { c };
6868
assert!(ASCII_LOWER_MAP[i] as char == lower)

parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use super::eq_ascii_lower;
2121
// TODO: Use a trait?
2222
enum ComponentValueIterator {
2323
ParserIter(~Parser),
24-
VectorIter(vec::VecConsumeIterator<(ComponentValue, SourceLocation)>),
24+
VectorIter(vec::ConsumeIterator<(ComponentValue, SourceLocation)>),
2525
}
2626

2727

@@ -43,7 +43,7 @@ impl ComponentValueIterator {
4343

4444
#[inline]
4545
pub fn next_non_whitespace(&mut self) -> Option<(ComponentValue, SourceLocation)> {
46-
for self.advance |(component_value, location)| {
46+
for (component_value, location) in *self {
4747
if component_value != WhiteSpace { return Some((component_value, location)) }
4848
}
4949
None
@@ -127,7 +127,7 @@ pub fn parse_declaration_or_at_rule(iter: &mut ComponentValueIterator)
127127
Ok(declaration) => Ok(Declaration(declaration)),
128128
Err(reason) => {
129129
// Find the end of the declaration
130-
for iter.advance |(v, _)| { if v == Semicolon { break } }
130+
for (v, _) in *iter { if v == Semicolon { break } }
131131
Err(reason)
132132
}
133133
}),

tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ fn almost_equals(a: &json::Json, b: &json::Json) -> bool {
3636
3737
fn assert_json_eq(results: json::Json, expected: json::Json, message: ~str) {
3838
if !almost_equals(&results, &expected) {
39-
let temp = tempfile::mkdtemp(&os::tmpdir(), "rust-cssparser-tests").get();
40-
let temp_ = copy temp;
39+
let temp = tempfile::mkdtemp(&os::tmpdir(), "rust-cssparser-tests").unwrap();
40+
let temp_ = temp.clone();
4141
let results = json::to_pretty_str(&results) + "\n";
4242
let expected = json::to_pretty_str(&expected) + "\n";
4343
do task::try {
@@ -62,11 +62,11 @@ fn run_json_tests(json_data: &str, parse: &fn (input: ~str) -> json::Json) {
6262
};
6363
assert!(items.len() % 2 == 0);
6464
let mut input: Option<~str> = None;
65-
for items.consume_iter().advance |item| {
65+
for item in items.consume_iter() {
6666
match (&input, item) {
6767
(&None, json::String(string)) => input = Some(string),
6868
(&Some(_), expected) => {
69-
let input = input.swap_unwrap();
69+
let input = input.take_unwrap();
7070
let result = parse(input.to_owned());
7171
assert_json_eq(result, expected, input);
7272
},

tokenizer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,9 @@ fn consume_numeric(parser: &mut Parser) -> ComponentValue {
429429
i64::from_str(representation)
430430
} else {
431431
i64::from_str(representation.slice_from(1))
432-
}.get()
432+
}.unwrap()
433433
)} else { None },
434-
value: f64::from_str(representation).get(),
434+
value: f64::from_str(representation).unwrap(),
435435
representation: representation,
436436
};
437437
if !parser.is_eof() && parser.current_char() == '%' {
@@ -599,5 +599,5 @@ fn consume_escape(parser: &mut Parser) -> char {
599599

600600
#[inline]
601601
fn char_from_hex(hex: &str) -> char {
602-
u32::from_str_radix(hex, 16).get() as char
602+
u32::from_str_radix(hex, 16).unwrap() as char
603603
}

0 commit comments

Comments
 (0)