Browse Source

downcast data with panic

Jonathan Kelley 1 năm trước cách đây
mục cha
commit
fc0b0f02a1
1 tập tin đã thay đổi với 7 bổ sung6 xóa
  1. 7 6
      packages/core/src/nodes.rs

+ 7 - 6
packages/core/src/nodes.rs

@@ -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,
+            });
+            // }
         }))
     }