Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'lib/smol_str/src/lib.rs')
-rw-r--r--lib/smol_str/src/lib.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/smol_str/src/lib.rs b/lib/smol_str/src/lib.rs
index 9f99153f2a..d819fe2dd9 100644
--- a/lib/smol_str/src/lib.rs
+++ b/lib/smol_str/src/lib.rs
@@ -6,11 +6,13 @@ extern crate core as std;
#[cfg(not(feature = "std"))]
extern crate alloc;
+use core::convert::Infallible;
use std::{
borrow::Borrow,
cmp::{self, Ordering},
fmt, hash, iter,
ops::Deref,
+ str::FromStr,
};
#[cfg(not(feature = "std"))]
@@ -316,6 +318,15 @@ impl Borrow<str> for SmolStr {
}
}
+impl FromStr for SmolStr {
+ type Err = Infallible;
+
+ #[inline]
+ fn from_str(s: &str) -> Result<SmolStr, Self::Err> {
+ Ok(SmolStr::from(s))
+ }
+}
+
#[cfg(feature = "arbitrary")]
impl<'a> arbitrary::Arbitrary<'a> for SmolStr {
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> Result<Self, arbitrary::Error> {