File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 18
18
19
19
#![ doc( html_root_url = "https://docs.rs/js-sys/0.2" ) ]
20
20
21
+ use std:: convert;
21
22
use std:: f64;
22
23
use std:: fmt;
23
24
use std:: mem;
25
+ use std:: str;
24
26
25
27
use wasm_bindgen:: prelude:: * ;
26
28
use wasm_bindgen:: JsCast ;
@@ -4297,6 +4299,13 @@ impl fmt::Debug for JsString {
4297
4299
}
4298
4300
}
4299
4301
4302
+ impl str:: FromStr for JsString {
4303
+ type Err = convert:: Infallible ;
4304
+ fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
4305
+ Ok ( JsString :: from ( s) )
4306
+ }
4307
+ }
4308
+
4300
4309
// Symbol
4301
4310
#[ wasm_bindgen]
4302
4311
extern "C" {
Original file line number Diff line number Diff line change 10
10
#![ doc( html_root_url = "https://docs.rs/wasm-bindgen/0.2" ) ]
11
11
#![ cfg_attr( feature = "nightly" , feature( unsize) ) ]
12
12
13
+ use core:: convert:: Infallible ;
13
14
use core:: fmt;
14
15
use core:: marker;
15
16
use core:: mem;
16
17
use core:: ops:: { Deref , DerefMut } ;
18
+ use core:: str:: FromStr ;
17
19
18
20
use crate :: convert:: { FromWasmAbi , WasmOptionalF64 , WasmSlice } ;
19
21
@@ -395,6 +397,13 @@ impl<'a> From<&'a str> for JsValue {
395
397
}
396
398
}
397
399
400
+ impl FromStr for JsValue {
401
+ type Err = Infallible ;
402
+ fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
403
+ Ok ( Self :: from_str ( s) )
404
+ }
405
+ }
406
+
398
407
if_std ! {
399
408
impl <' a> From <& ' a String > for JsValue {
400
409
#[ inline]
You can’t perform that action at this time.
0 commit comments