mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Add doc-comments about methods that can panic
https://github.com/servo/servo/pull/7683/files#r40072222
This commit is contained in:
parent
74e4c4fdc7
commit
770e3bab35
1 changed files with 19 additions and 0 deletions
|
@ -74,6 +74,11 @@ impl AttrValue {
|
|||
AttrValue::Atom(value)
|
||||
}
|
||||
|
||||
/// Assumes the `AttrValue` is a `TokenList` and returns its tokens
|
||||
///
|
||||
/// ## Panics
|
||||
///
|
||||
/// Panics if the `AttrValue` is not a `TokenList`
|
||||
pub fn as_tokens(&self) -> &[Atom] {
|
||||
match *self {
|
||||
AttrValue::TokenList(_, ref tokens) => tokens,
|
||||
|
@ -81,6 +86,11 @@ impl AttrValue {
|
|||
}
|
||||
}
|
||||
|
||||
/// Assumes the `AttrValue` is an `Atom` and returns its value
|
||||
///
|
||||
/// ## Panics
|
||||
///
|
||||
/// Panics if the `AttrValue` is not an `Atom`
|
||||
pub fn as_atom(&self) -> &Atom {
|
||||
match *self {
|
||||
AttrValue::Atom(ref value) => value,
|
||||
|
@ -88,6 +98,11 @@ impl AttrValue {
|
|||
}
|
||||
}
|
||||
|
||||
/// Assumes the `AttrValue` is a `Length` and returns its value
|
||||
///
|
||||
/// ## Panics
|
||||
///
|
||||
/// Panics if the `AttrValue` is not a `Length`
|
||||
pub fn as_length(&self) -> Option<&Length> {
|
||||
match *self {
|
||||
AttrValue::Length(_, ref length) => length.as_ref(),
|
||||
|
@ -98,6 +113,10 @@ impl AttrValue {
|
|||
/// Return the AttrValue as its integer representation, if any.
|
||||
/// This corresponds to attribute values returned as `AttrValue::UInt(_)`
|
||||
/// by `VirtualMethods::parse_plain_attribute()`.
|
||||
///
|
||||
/// ## Panics
|
||||
///
|
||||
/// Panics if the `AttrValue` is not a `UInt`
|
||||
pub fn as_uint(&self) -> u32 {
|
||||
if let AttrValue::UInt(_, value) = *self {
|
||||
value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue