From 3061bc795e4f3abe1d51b0b60c08cea2f89e02c6 Mon Sep 17 00:00:00 2001 From: timvisee Date: Thu, 24 Apr 2025 11:06:39 +0200 Subject: [PATCH] Implement FromStr on EcoString --- src/string.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/string.rs b/src/string.rs index 6705cc9..cb7c298 100644 --- a/src/string.rs +++ b/src/string.rs @@ -6,6 +6,7 @@ use core::cmp::Ordering; use core::fmt::{self, Debug, Display, Formatter, Write}; use core::hash::{Hash, Hasher}; use core::ops::{Add, AddAssign, Deref}; +use core::str::FromStr; #[cfg(not(feature = "std"))] use alloc::string::String; @@ -521,6 +522,15 @@ impl From<&EcoString> for String { } } +impl FromStr for EcoString { + type Err = core::convert::Infallible; + + #[inline] + fn from_str(s: &str) -> Result { + Ok(Self::from_str(s)) + } +} + #[cold] const fn exceeded_inline_capacity() -> ! { panic!("exceeded inline capacity");