Add variants method to symbol

This commit is contained in:
Laurenz 2023-01-27 19:27:15 +01:00
parent a96141a3ea
commit c7c135f25e

View File

@ -81,12 +81,12 @@ impl Symbol {
}
/// The characters that are covered by this symbol.
pub fn chars(&self) -> impl Iterator<Item = char> {
pub fn variants(&self) -> impl Iterator<Item = (&str, char)> {
let (first, slice) = match self.repr {
Repr::Single(c) => (Some(c), [].as_slice()),
Repr::Single(c) => (Some(("", c)), [].as_slice()),
Repr::List(list) => (None, list),
};
first.into_iter().chain(slice.iter().map(|&(_, c)| c))
first.into_iter().chain(slice.iter().copied())
}
/// Possible modifiers.