mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Remove the implementation OptionalSettable for Option<JS<T>> to remove needless '&mut self'.
This commit is contained in:
parent
a0a0e07f71
commit
ad22b29b2d
1 changed files with 3 additions and 11 deletions
|
@ -260,20 +260,12 @@ impl<T: Reflectable> Assignable<T> for Temporary<T> {
|
||||||
/// Assign an optional rootable value (either of JS<T> or Temporary<T>) to an optional
|
/// Assign an optional rootable value (either of JS<T> or Temporary<T>) to an optional
|
||||||
/// field of a DOM type (ie. Option<JS<T>>)
|
/// field of a DOM type (ie. Option<JS<T>>)
|
||||||
pub trait OptionalSettable<T> {
|
pub trait OptionalSettable<T> {
|
||||||
fn assign(&mut self, val: Option<T>);
|
fn assign(&self, val: Option<T>);
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Assignable<U>, U: Reflectable> OptionalSettable<T> for Option<JS<U>> {
|
|
||||||
fn assign(&mut self, val: Option<T>) {
|
|
||||||
*self = val.map(|val| unsafe { val.get_js() });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Assignable<U>, U: Reflectable> OptionalSettable<T> for Cell<Option<JS<U>>> {
|
impl<T: Assignable<U>, U: Reflectable> OptionalSettable<T> for Cell<Option<JS<U>>> {
|
||||||
fn assign(&mut self, val: Option<T>) {
|
fn assign(&self, val: Option<T>) {
|
||||||
let mut item = self.get();
|
self.set(val.map(|val| unsafe { val.get_js() }));
|
||||||
item.assign(val);
|
|
||||||
self.set(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue