From e59f6468709e8d971474b960ae75ee3c70dde20a Mon Sep 17 00:00:00 2001 From: Taus Date: Fri, 26 Jun 2026 14:02:25 +0000 Subject: [PATCH] yeast: Remove dead Captures methods `Captures::map_captures`, `Captures::map_captures_to`, and `Captures::try_map_all_captures` had no callers. The last one was subsumed by `try_map_captures_except` (which takes a skip list and degenerates to the old behaviour when the list is empty). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- shared/yeast/src/captures.rs | 46 +++++++----------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/shared/yeast/src/captures.rs b/shared/yeast/src/captures.rs index 101ab329220..93141ef0084 100644 --- a/shared/yeast/src/captures.rs +++ b/shared/yeast/src/captures.rs @@ -54,37 +54,15 @@ impl Captures { self.captures.entry(key).or_default().push(id); } - pub fn map_captures(&mut self, kind: &str, f: &mut impl FnMut(Id) -> Id) { - if let Some(ids) = self.captures.get_mut(kind) { - for id in ids { - *id = f(*id); - } - } - } - - /// Apply a fallible function to every captured id (across all keys), - /// replacing each id with the results. A function returning an empty - /// vector removes the capture; returning multiple ids splices them - /// into the capture's value list (suitable for `*`/`+` captures). - /// Stops and returns the error on the first failure. - pub fn try_map_all_captures( - &mut self, - mut f: impl FnMut(Id) -> Result, E>, - ) -> Result<(), E> { - for ids in self.captures.values_mut() { - let mut new_ids = Vec::with_capacity(ids.len()); - for &id in ids.iter() { - new_ids.extend(f(id)?); - } - *ids = new_ids; - } - Ok(()) - } - - /// Like [`try_map_all_captures`] but leaves captures whose name appears - /// in `skip` untouched. Used by the `rule!` macro to support `@@name` - /// (raw) captures alongside the default auto-translated `@name` - /// captures. + /// Apply a fallible function to every captured id, replacing each id + /// with the results. A function returning an empty vector removes + /// the capture; returning multiple ids splices them into the + /// capture's value list (suitable for `*`/`+` captures). Captures + /// whose name appears in `skip` are left untouched. Stops and + /// returns the error on the first failure. + /// + /// Used by the `rule!` macro's auto-translate prefix to translate + /// every capture except those marked `@@name` (raw). pub fn try_map_captures_except( &mut self, skip: &[&str], @@ -102,12 +80,6 @@ impl Captures { } Ok(()) } - pub fn map_captures_to(&mut self, from: &str, to: &'static str, f: &mut impl FnMut(Id) -> Id) { - if let Some(from_ids) = self.captures.get(from) { - let new_values = from_ids.iter().copied().map(f).collect(); - self.captures.insert(to, new_values); - } - } pub fn merge(&mut self, other: &Captures) { for (key, ids) in &other.captures {