From 3db1f9fe5dce6014097557f1e6c11fa08167c5bb Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Mon, 13 May 2024 19:46:41 +0900 Subject: [PATCH] revset: extract aliases_map.function_names() TemplateAliasesMap has a similar function for symbols, and I'm going to extract a common aliases map type. --- lib/src/revset_parser.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/src/revset_parser.rs b/lib/src/revset_parser.rs index 76c8fc3be..7f65f19cb 100644 --- a/lib/src/revset_parser.rs +++ b/lib/src/revset_parser.rs @@ -542,11 +542,7 @@ fn parse_function_expression( name, itertools::chain( state.function_map.keys().copied(), - state - .aliases_map - .function_aliases - .keys() - .map(|n| n.as_ref()), + state.aliases_map.function_names(), ), ), }, @@ -586,6 +582,11 @@ impl RevsetAliasesMap { Ok(()) } + /// Iterates function names in arbitrary order. + pub fn function_names(&self) -> impl Iterator { + self.function_aliases.keys().map(|n| n.as_ref()) + } + pub fn get_symbol(&self, name: &str) -> Option<&str> { self.symbol_aliases.get(name).map(|defn| defn.as_ref()) }