summaryrefslogtreecommitdiff
path: root/src/util/eco_string.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-10-17 14:38:48 +0200
committerLaurenz <laurmaedje@gmail.com>2021-10-23 20:23:47 +0200
commit5becb32ba463d6b0ace914ab06bb237483a94fbc (patch)
tree684efb242ddb04e71c54f9665cc59891f734e518 /src/util/eco_string.rs
parentc627847cb39572c08f3b53db07ea325ef0d352fa (diff)
Introduce page / block / inline levels
Diffstat (limited to 'src/util/eco_string.rs')
-rw-r--r--src/util/eco_string.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/util/eco_string.rs b/src/util/eco_string.rs
index f1dfdfaf..ab8d5642 100644
--- a/src/util/eco_string.rs
+++ b/src/util/eco_string.rs
@@ -5,6 +5,8 @@ use std::hash::{Hash, Hasher};
use std::ops::Deref;
use std::rc::Rc;
+use super::RcExt;
+
/// An economical string with inline storage and clone-on-write semantics.
#[derive(Clone)]
pub struct EcoString(Repr);
@@ -293,10 +295,7 @@ 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(),
- },
+ Repr::Large(rc) => Rc::take(rc),
}
}
}