diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-07-31 22:59:14 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-08-01 00:00:36 +0200 |
| commit | 3c92bad9a7cd6b880de197806443ffcce2cac9d8 (patch) | |
| tree | 1faf79c66e23bc37711af16ad690a9878e28d348 /src/util | |
| parent | fbd3d191137aac8188ab8c6503d257d65d873972 (diff) | |
Pretty-printed diagnostics with traceback
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/eco.rs | 18 |
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; |
