Implement OptionalSettable for 'Cell<Option<JS<U>>>'.

This commit is contained in:
Tetsuharu OHZEKI 2014-05-28 05:32:54 +09:00
parent b0239b5a5a
commit 92da2f16fc

View file

@ -47,7 +47,7 @@ use layout_interface::TrustedNodeAddress;
use script_task::StackRoots;
use std::cast;
use std::cell::RefCell;
use std::cell::{Cell, RefCell};
use std::kinds::marker::ContravariantLifetime;
/// A type that represents a JS-owned value that is rooted for the lifetime of this value.
@ -269,6 +269,15 @@ impl<T: Assignable<U>, U: Reflectable> OptionalSettable<T> for Option<JS<U>> {
}
}
impl<T: Assignable<U>, U: Reflectable> OptionalSettable<T> for Cell<Option<JS<U>>> {
fn assign(&mut self, val: Option<T>) {
let mut item = self.get();
item.assign(val);
self.set(item);
}
}
/// Root a rootable Option type (used for Option<Temporary<T>>)
pub trait OptionalRootable<T> {
fn root<'a, 'b>(self) -> Option<Root<'a, 'b, T>>;