From fa92de40a956b732bc5ad7fc6688a924269fa050 Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 17 Jul 2026 00:32:47 +0200 Subject: feat(engine-reflection): add try_get_len fn to slice reflection --- engine-reflection/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engine-reflection/src/lib.rs b/engine-reflection/src/lib.rs index d9e2c72..76dc71d 100644 --- a/engine-reflection/src/lib.rs +++ b/engine-reflection/src/lib.rs @@ -313,6 +313,7 @@ pub struct Slice pub item_layout: Layout, pub get_item_type_name: FnWithDebug<&'static str>, pub try_get_item: fn(target: &dyn Any, index: usize) -> Result<&dyn Any, GetError>, + pub try_get_len: fn(target: &dyn Any) -> Option, } impl Slice @@ -477,6 +478,11 @@ unsafe impl Reflection for &'static [T] Ok(item) }, + try_get_len: |target| { + let target = target.downcast_ref::()?; + + Some(target.len()) + }, }); } -- cgit v1.2.3-18-g5258