Make sixtyfps::Weak<T>::upgrade_in_event_loop easier to use

... by taking &self instead of self

cc #431
This commit is contained in:
Simon Hausmann 2022-01-27 11:23:56 +01:00 committed by Simon Hausmann
parent 9e03d9b718
commit a79f3c7185

View file

@ -653,12 +653,13 @@ mod weak_handle {
/// handle.run(); /// handle.run();
/// ``` /// ```
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub fn upgrade_in_event_loop(self, func: impl FnOnce(T) + Send + 'static) pub fn upgrade_in_event_loop(&self, func: impl FnOnce(T) + Send + 'static)
where where
T: 'static, T: 'static,
{ {
let weak_handle = self.clone();
crate::invoke_from_event_loop(move || { crate::invoke_from_event_loop(move || {
if let Some(h) = self.upgrade() { if let Some(h) = weak_handle.upgrade() {
func(h); func(h);
} }
}) })