Skip to content

Commit 59fd0f7

Browse files
committed
Merge pull request #9 from SimonSapin/color-parse-method
Make parse_color a static method Color::parse
2 parents 5b55b42 + 142035a commit 59fd0f7

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

ast.rs

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ impl<'self> SkipWhitespaceIterable<'self> for &'self [ComponentValue] {
138138
}
139139
}
140140

141+
#[deriving(Clone)]
141142
pub struct SkipWhitespaceIterator<'self> {
142143
iter_with_whitespace: vec::VecIterator<'self, ComponentValue>,
143144
}

color.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ pub enum Color {
2222

2323

2424
// Return None on invalid/unsupported value (not a color)
25-
pub fn parse_color(component_value: &ComponentValue) -> Option<Color> {
26-
match *component_value {
27-
Hash(ref value) | IDHash(ref value) => parse_color_hash(*value),
28-
Ident(ref value) => parse_color_keyword(*value),
29-
Function(ref name, ref arguments) => parse_color_function(*name, *arguments),
30-
_ => None
25+
impl Color {
26+
pub fn parse(component_value: &ComponentValue) -> Option<Color> {
27+
match *component_value {
28+
Hash(ref value) | IDHash(ref value) => parse_color_hash(*value),
29+
Ident(ref value) => parse_color_keyword(*value),
30+
Function(ref name, ref arguments) => parse_color_function(*name, *arguments),
31+
_ => None
32+
}
3133
}
3234
}
3335

0 commit comments

Comments
 (0)