diff options
Diffstat (limited to 'isabelle-unicode/src')
-rw-r--r-- | isabelle-unicode/src/lib.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/isabelle-unicode/src/lib.rs b/isabelle-unicode/src/lib.rs index 8394e57..30a7cec 100644 --- a/isabelle-unicode/src/lib.rs +++ b/isabelle-unicode/src/lib.rs @@ -1,13 +1,15 @@ symbolmacro::make_symbols!(); -// TODO: is it possible to be polymorphic over slice types here? pub trait PrettyUnicode { - fn to_pretty_unicode(self) -> Option<String>; + type Owned: core::borrow::Borrow<Self>; + fn to_pretty_unicode(&self) -> Option<Self::Owned>; } -impl PrettyUnicode for &str { - fn to_pretty_unicode(self) -> Option<String> { +impl PrettyUnicode for str { + type Owned = String; + + fn to_pretty_unicode(&self) -> Option<Self::Owned> { // split at escape sequences let mut chunks = self.split("\\<"); @@ -30,7 +32,7 @@ impl PrettyUnicode for &str { // how much of the rest do we need? let offset = ident? - .len() + .len() + 1; Some((symbol, &chunk[offset..])) }) |