diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2018-07-06 11:14:44 -0700 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2018-07-06 13:10:56 -0700 |
commit | cceaede96a18e67d93c087d6d499f27eda022025 (patch) | |
tree | b996f245a09434a0bd4f69e3e13c2e531885a950 /components/script/dom/bindings/iterable.rs | |
parent | c90737e6c8b9436919706f9490ba6d05492b7121 (diff) | |
download | servo-cceaede96a18e67d93c087d6d499f27eda022025.tar.gz servo-cceaede96a18e67d93c087d6d499f27eda022025.zip |
Make (dictionary)::empty() safe
It currently works by constructing from null (which will throw a runtime
error if there are non-defaultable members).
This changes it so that we no longer need a JSContext to construct this,
so it can be safely constructed. In the case of non-defaultable members,
this method simply does not exist.
Diffstat (limited to 'components/script/dom/bindings/iterable.rs')
-rw-r--r-- | components/script/dom/bindings/iterable.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/components/script/dom/bindings/iterable.rs b/components/script/dom/bindings/iterable.rs index 15ccd554c2a..87ee05541fa 100644 --- a/components/script/dom/bindings/iterable.rs +++ b/components/script/dom/bindings/iterable.rs @@ -115,7 +115,7 @@ fn dict_return(cx: *mut JSContext, mut result: MutableHandleObject, done: bool, value: HandleValue) -> Fallible<()> { - let mut dict = unsafe { IterableKeyOrValueResult::empty(cx) }; + let mut dict = IterableKeyOrValueResult::empty(); dict.done = done; dict.value.set(value.get()); rooted!(in(cx) let mut dict_value = UndefinedValue()); @@ -130,7 +130,7 @@ fn key_and_value_return(cx: *mut JSContext, mut result: MutableHandleObject, key: HandleValue, value: HandleValue) -> Fallible<()> { - let mut dict = unsafe { IterableKeyAndValueResult::empty(cx) }; + let mut dict = IterableKeyAndValueResult::empty(); dict.done = false; dict.value = Some(vec![key, value] .into_iter() |