Skip to content

Commit fbd3286

Browse files
committed
Add FromStr impl for Yarn
1 parent 82c9cb1 commit fbd3286

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

byteyarn/src/convert.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::borrow::Borrow;
2+
use std::convert::Infallible;
23
use std::fmt;
4+
use std::str::FromStr;
35
use std::str::Utf8Error;
46

57
use crate::YarnBox;
@@ -224,6 +226,14 @@ impl From<YarnRef<'_, str>> for String {
224226
}
225227
}
226228

229+
impl FromStr for YarnBox<'static, str> {
230+
type Err = Infallible;
231+
232+
fn from_str(s: &str) -> Result<Self, Self::Err> {
233+
Ok(Self::copy(s))
234+
}
235+
}
236+
227237
// AsRef / Borrow
228238

229239
impl<Buf> AsRef<Buf> for YarnBox<'_, Buf>

0 commit comments

Comments
 (0)