This commit is contained in:
T0mstone 2025-07-10 02:04:51 +02:00
parent 3fba007c13
commit fd35268a88

View File

@ -102,10 +102,10 @@ impl Symbol {
match &self.0 { match &self.0 {
Repr::Single(value) => value, Repr::Single(value) => value,
Repr::Complex(_) => ModifierSet::<&'static str>::default() Repr::Complex(_) => ModifierSet::<&'static str>::default()
.best_match_in(self.variants().map(|(m, c, _)| (m, c))) .best_match_in(self.variants().map(|(m, v, _)| (m, v)))
.unwrap(), .unwrap(),
Repr::Modified(arc) => { Repr::Modified(arc) => {
arc.1.best_match_in(self.variants().map(|(m, c, _)| (m, c))).unwrap() arc.1.best_match_in(self.variants().map(|(m, v, _)| (m, v))).unwrap()
} }
} }
} }
@ -168,7 +168,7 @@ impl Symbol {
/// The characters that are covered by this symbol. /// The characters that are covered by this symbol.
pub fn variants(&self) -> impl Iterator<Item = Variant<&str>> { pub fn variants(&self) -> impl Iterator<Item = Variant<&str>> {
match &self.0 { match &self.0 {
Repr::Single(value) => Variants::Single(Some(*value).into_iter()), Repr::Single(value) => Variants::Single(std::iter::once(*value)),
Repr::Complex(list) => Variants::Static(list.iter()), Repr::Complex(list) => Variants::Static(list.iter()),
Repr::Modified(arc) => arc.0.variants(), Repr::Modified(arc) => arc.0.variants(),
} }
@ -291,7 +291,7 @@ impl Display for Symbol {
impl Debug for Repr { impl Debug for Repr {
fn fmt(&self, f: &mut Formatter) -> fmt::Result { fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self { match self {
Self::Single(c) => Debug::fmt(c, f), Self::Single(value) => Debug::fmt(value, f),
Self::Complex(list) => list.fmt(f), Self::Complex(list) => list.fmt(f),
Self::Modified(lists) => lists.fmt(f), Self::Modified(lists) => lists.fmt(f),
} }
@ -399,7 +399,7 @@ cast! {
/// Iterator over variants. /// Iterator over variants.
enum Variants<'a> { enum Variants<'a> {
Single(std::option::IntoIter<&'static str>), Single(std::iter::Once<&'static str>),
Static(std::slice::Iter<'static, Variant<&'static str>>), Static(std::slice::Iter<'static, Variant<&'static str>>),
Runtime(std::slice::Iter<'a, Variant<EcoString>>), Runtime(std::slice::Iter<'a, Variant<EcoString>>),
} }