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.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/smol_str/src/lib.rs b/lib/smol_str/src/lib.rs
index 91dc6252cc..f09d0010c4 100644
--- a/lib/smol_str/src/lib.rs
+++ b/lib/smol_str/src/lib.rs
@@ -334,6 +334,13 @@ impl From<Box<str>> for SmolStr {
}
}
+impl From<Arc<str>> for SmolStr {
+ #[inline]
+ fn from(s: Arc<str>) -> SmolStr {
+ SmolStr(Repr::Heap(s))
+ }
+}
+
impl<'a> From<Cow<'a, str>> for SmolStr {
#[inline]
fn from(s: Cow<'a, str>) -> SmolStr {
@@ -341,6 +348,16 @@ impl<'a> From<Cow<'a, str>> for SmolStr {
}
}
+impl From<SmolStr> for Arc<str> {
+ #[inline(always)]
+ fn from(text: SmolStr) -> Self {
+ match text.0 {
+ Repr::Heap(data) => data,
+ _ => text.as_str().into(),
+ }
+ }
+}
+
impl From<SmolStr> for String {
#[inline(always)]
fn from(text: SmolStr) -> Self {