mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
renaming tokens(), atom() and uint() and rewriting to return or panic
This commit is contained in:
parent
eaf90c0b1c
commit
105ea0d690
8 changed files with 31 additions and 35 deletions
|
@ -75,28 +75,28 @@ impl AttrValue {
|
|||
AttrValue::Atom(value)
|
||||
}
|
||||
|
||||
pub fn tokens<'a>(&'a self) -> Option<&'a [Atom]> {
|
||||
pub fn as_tokens<'a>(&'a self) -> &'a [Atom] {
|
||||
match *self {
|
||||
AttrValue::TokenList(_, ref tokens) => Some(tokens),
|
||||
_ => None
|
||||
AttrValue::TokenList(_, ref tokens) => tokens,
|
||||
_ => panic!("Tokens not found"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn atom<'a>(&'a self) -> Option<&'a Atom> {
|
||||
pub fn as_atom<'a>(&'a self) -> &'a Atom {
|
||||
match *self {
|
||||
AttrValue::Atom(ref value) => Some(value),
|
||||
_ => None
|
||||
AttrValue::Atom(ref value) => value,
|
||||
_ => panic!("Atom not found"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the AttrValue as its integer representation, if any.
|
||||
/// This corresponds to attribute values returned as `AttrValue::UInt(_)`
|
||||
/// by `VirtualMethods::parse_plain_attribute()`.
|
||||
pub fn uint(&self) -> Option<u32> {
|
||||
pub fn as_uint(&self) -> u32 {
|
||||
if let AttrValue::UInt(_, value) = *self {
|
||||
Some(value)
|
||||
value
|
||||
} else {
|
||||
None
|
||||
panic!("Uint not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue