From e1c53ff259fd597ee3ccbea19e3b6da90e4eacde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tau=20G=C3=A4rtli?= Date: Fri, 6 Sep 2024 17:22:41 +0200 Subject: [PATCH] Add return value to with_accessibility_parent --- crates/egui/src/context.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 162ff4a739e..81f0c0a9624 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -2887,9 +2887,9 @@ impl Context { /// the function is still called, but with no other effect. /// /// No locks are held while the given closure is called. - #[allow(clippy::unused_self)] + #[allow(clippy::unused_self, clippy::let_and_return)] #[inline] - pub fn with_accessibility_parent(&self, _id: Id, f: impl FnOnce()) { + pub fn with_accessibility_parent(&self, _id: Id, f: impl FnOnce() -> R) -> R { // TODO(emilk): this isn't thread-safe - another thread can call this function between the push/pop calls #[cfg(feature = "accesskit")] self.frame_state_mut(|fs| { @@ -2898,7 +2898,7 @@ impl Context { } }); - f(); + let result = f(); #[cfg(feature = "accesskit")] self.frame_state_mut(|fs| { @@ -2906,6 +2906,8 @@ impl Context { assert_eq!(state.parent_stack.pop(), Some(_id)); } }); + + result } /// If AccessKit support is active for the current frame, get or create