From fbd328680daa0174339318eae6c657e268f4d75e Mon Sep 17 00:00:00 2001 From: Paul Weaver Date: Wed, 13 Dec 2023 23:10:28 +0000 Subject: [PATCH] Add FromStr impl for Yarn --- byteyarn/src/convert.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/byteyarn/src/convert.rs b/byteyarn/src/convert.rs index 6d33745..30b1836 100644 --- a/byteyarn/src/convert.rs +++ b/byteyarn/src/convert.rs @@ -1,5 +1,7 @@ use std::borrow::Borrow; +use std::convert::Infallible; use std::fmt; +use std::str::FromStr; use std::str::Utf8Error; use crate::YarnBox; @@ -224,6 +226,14 @@ impl From> for String { } } +impl FromStr for YarnBox<'static, str> { + type Err = Infallible; + + fn from_str(s: &str) -> Result { + Ok(Self::copy(s)) + } +} + // AsRef / Borrow impl AsRef for YarnBox<'_, Buf>