Skip to content

Commit 16a33a9

Browse files
committed
Add FromStr impl for Yarn
1 parent 07c78ef commit 16a33a9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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;
@@ -209,6 +211,14 @@ impl From<YarnRef<'_, str>> for String {
209211
}
210212
}
211213

214+
impl FromStr for YarnBox<'static, str> {
215+
type Err = Infallible;
216+
217+
fn from_str(s: &str) -> Result<Self, Self::Err> {
218+
Ok(Self::copy(s))
219+
}
220+
}
221+
212222
// AsRef / Borrow
213223

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

0 commit comments

Comments
 (0)