mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-13 13:01:22 +00:00
Remove casting to &mut T
for JS casts
I discussed this with @fitzgen awhile back and this sort of casting seems especially problematic when you have code along the lines of: let mut x: HtmlElement = ...; { let y: &mut JsValue = x.as_ref(); *y = 3.into(); } x.some_html_element_method(); as that will immediately throw! We didn't have a use case for mutable casting other than consistency, so this commit removes it for now. We can possibly add it back in later if motivated, but for now it seems reasonable to try to avoid these sorts of pitfalls!
This commit is contained in:
@ -370,11 +370,6 @@ impl JsCast for JsValue {
|
||||
fn instanceof(_val: &JsValue) -> bool { true }
|
||||
fn unchecked_from_js(val: JsValue) -> Self { val }
|
||||
fn unchecked_from_js_ref(val: &JsValue) -> &Self { val }
|
||||
fn unchecked_from_js_mut(val: &mut JsValue) -> &mut Self { val }
|
||||
}
|
||||
|
||||
impl AsMut<JsValue> for JsValue {
|
||||
fn as_mut(&mut self) -> &mut JsValue { self }
|
||||
}
|
||||
|
||||
impl AsRef<JsValue> for JsValue {
|
||||
|
Reference in New Issue
Block a user