Skip to content

Commit c2f6b00

Browse files
Implement FromStr for JsString (#2625)
1 parent 7caeb31 commit c2f6b00

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/js-sys/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
1919
#![doc(html_root_url = "https://docs.rs/js-sys/0.2")]
2020

21+
use std::convert;
2122
use std::f64;
2223
use std::fmt;
2324
use std::mem;
25+
use std::str;
2426

2527
use wasm_bindgen::prelude::*;
2628
use wasm_bindgen::JsCast;
@@ -4297,6 +4299,13 @@ impl fmt::Debug for JsString {
42974299
}
42984300
}
42994301

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+
43004309
// Symbol
43014310
#[wasm_bindgen]
43024311
extern "C" {

0 commit comments

Comments
 (0)