mirror of
https://github.com/servo/servo.git
synced 2025-06-19 06:38:59 +01:00
Use Result/Err(()) instead of Option/None to indicate a CSS parse error.
This commit is contained in:
parent
061e7e1620
commit
d9278e3f6a
6 changed files with 223 additions and 212 deletions
|
@ -7,15 +7,18 @@ use std::ascii::StrAsciiExt;
|
|||
use cssparser::ast::{ComponentValue, Ident, SkipWhitespaceIterable};
|
||||
|
||||
|
||||
pub fn one_component_value<'a>(input: &'a [ComponentValue]) -> Option<&'a ComponentValue> {
|
||||
pub fn one_component_value<'a>(input: &'a [ComponentValue]) -> Result<&'a ComponentValue, ()> {
|
||||
let mut iter = input.skip_whitespace();
|
||||
iter.next().filtered(|_| iter.next().is_none())
|
||||
}
|
||||
|
||||
|
||||
pub fn get_ident_lower(component_value: &ComponentValue) -> Option<String> {
|
||||
match component_value {
|
||||
&Ident(ref value) => Some(value.as_slice().to_ascii_lower()),
|
||||
_ => None,
|
||||
match iter.next() {
|
||||
Some(value) => if iter.next().is_none() { Ok(value) } else { Err(()) },
|
||||
None => Err(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn get_ident_lower(component_value: &ComponentValue) -> Result<String, ()> {
|
||||
match component_value {
|
||||
&Ident(ref value) => Ok(value.as_slice().to_ascii_lower()),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue