mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implement RootedReference<T> for Option<JS<T>>
An implementation of RootedReference for Option<JS<T>> based off of other implementations of RootedReference for Option wrapped types.
This commit is contained in:
parent
f0d4c03bd9
commit
7a35ef1555
3 changed files with 10 additions and 3 deletions
|
@ -444,6 +444,13 @@ impl<T: Reflectable> RootedReference<T> for Option<Root<T>> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Get an `Option<&T> out of an `Option<JS<T>>`
|
||||
impl<T: Reflectable> RootedReference<T> for Option<JS<T>> {
|
||||
fn r(&self) -> Option<&T> {
|
||||
self.as_ref().map(|inner| &**inner)
|
||||
}
|
||||
}
|
||||
|
||||
/// Get an `Option<Option<&T>>` out of an `Option<Option<Root<T>>>`
|
||||
pub trait OptionalRootedReference<T> {
|
||||
/// Obtain a safe optional optional reference to the wrapped JS owned-value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue