From 8f800f9b2b41ff10fa77c2b8eb3bf08a7090c60b Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Thu, 30 Jan 2025 11:42:10 +0100 Subject: [PATCH] process_comment: Use last defined callback Instead of using the last registered callback, iterate through all callbacks and use the last one that was actually implemented and returned `Some()`. This is essentially when users register more than one parse callback - the process_comment may not be the last. --- bindgen/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bindgen/lib.rs b/bindgen/lib.rs index 9e22e37ce6..6d15012704 100644 --- a/bindgen/lib.rs +++ b/bindgen/lib.rs @@ -582,9 +582,7 @@ impl BindgenOptions { fn process_comment(&self, comment: &str) -> String { let comment = comment::preprocess(comment); - self.parse_callbacks - .last() - .and_then(|cb| cb.process_comment(&comment)) + self.last_callback(|cb| cb.process_comment(&comment)) .unwrap_or(comment) } }