diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-03-31 11:43:07 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-03-31 11:43:07 +0800 |
| commit | a1503fef9947732994d4fb866b90b665c846b547 (patch) | |
| tree | 1542c91bad27df973993a862dcf49ee472e976f9 /mingling_core/src/program.rs | |
| parent | 5a56cfd5e5ee7cde191b4c4fb24c6d11638f75fa (diff) | |
Update mingling_core to version 0.1.2 and use local dependencies
- Replace registry dependencies with local path dependencies
- Bump mingling_core version from 0.1.1 to 0.1.2
- Add safety comments for unsafe downcast operations
Diffstat (limited to 'mingling_core/src/program.rs')
| -rw-r--r-- | mingling_core/src/program.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/mingling_core/src/program.rs b/mingling_core/src/program.rs index 1f234af..b13a879 100644 --- a/mingling_core/src/program.rs +++ b/mingling_core/src/program.rs @@ -93,7 +93,9 @@ macro_rules! __dispatch_program_renderers { match any.type_id { $( id if id == std::any::TypeId::of::<$prev_ty>() => { - let value = any.downcast::<$prev_ty>().unwrap(); + // SAFETY: The `type_id` check ensures that `any` contains a value of type `$chain_prev`, + // so downcasting to `$chain_prev` is safe. + let value = unsafe { any.downcast::<$prev_ty>().unwrap_unchecked() }; <$render_ty as mingling::Renderer>::render(value, r); } )* @@ -115,7 +117,9 @@ macro_rules! __dispatch_program_chains { match any.type_id { $( id if id == std::any::TypeId::of::<$chain_prev>() => { - let value = any.downcast::<$chain_prev>().unwrap(); + // SAFETY: The `type_id` check ensures that `any` contains a value of type `$chain_prev`, + // so downcasting to `$chain_prev` is safe. + let value = unsafe { any.downcast::<$chain_prev>().unwrap_unchecked() }; let fut = async { <$chain_ty as mingling::Chain>::proc(value).await }; Box::pin(fut) } |
