downcast data with panic

This commit is contained in:
Jonathan Kelley 2024-01-20 11:21:49 -08:00
parent 3ded0f5329
commit fc0b0f02a1
No known key found for this signature in database
GPG key ID: 1FBB50F7EB0A08BE

View file

@ -696,12 +696,13 @@ impl AttributeValue {
/// The callback must be confined to the lifetime of the ScopeState
pub fn listener<T: 'static>(mut callback: impl FnMut(Event<T>) + 'static) -> AttributeValue {
AttributeValue::Listener(EventHandler::new(move |event: Event<dyn Any>| {
if let Ok(data) = event.data.downcast::<T>() {
callback(Event {
propagates: event.propagates,
data,
});
}
let data = event.data.downcast::<T>().unwrap();
// if let Ok(data) = event.data.downcast::<T>() {
callback(Event {
propagates: event.propagates,
data,
});
// }
}))
}