summaryrefslogtreecommitdiff
path: root/src/util/eco.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/eco.rs')
-rw-r--r--src/util/eco.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/util/eco.rs b/src/util/eco.rs
index 7fe1ac9c..00f87872 100644
--- a/src/util/eco.rs
+++ b/src/util/eco.rs
@@ -193,6 +193,24 @@ impl From<&String> for EcoString {
}
}
+impl From<EcoString> for String {
+ fn from(s: EcoString) -> Self {
+ match s.0 {
+ Repr::Small { .. } => s.as_str().to_owned(),
+ Repr::Large(rc) => match Rc::try_unwrap(rc) {
+ Ok(string) => string,
+ Err(rc) => (*rc).clone(),
+ },
+ }
+ }
+}
+
+impl From<&EcoString> for String {
+ fn from(s: &EcoString) -> Self {
+ s.as_str().to_owned()
+ }
+}
+
impl Deref for EcoString {
type Target = str;