From 318ec09d7d584bc7bbe9fa9d1ee26b1c690d9b54 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Thu, 11 Apr 2019 19:24:22 +0100 Subject: [PATCH] Update `JsString::try_from` to use new `dyn_ref` --- crates/js-sys/src/lib.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/crates/js-sys/src/lib.rs b/crates/js-sys/src/lib.rs index b7ed0424643..804c2558e3c 100644 --- a/crates/js-sys/src/lib.rs +++ b/crates/js-sys/src/lib.rs @@ -3515,11 +3515,7 @@ impl JsString { /// If this JS value is not an instance of a string then this returns /// `None`. pub fn try_from(val: &JsValue) -> Option<&JsString> { - if val.is_string() { - Some(unsafe { mem::transmute(val) }) - } else { - None - } + val.dyn_ref() } /// Returns whether this string is a valid UTF-16 string.