diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-04-05 20:47:03 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-04-05 20:47:03 +0800 |
| commit | ba0adc2fa0c42a3646d50d499558bc532eae2cba (patch) | |
| tree | a1e936f49665739c14f8ae72f11b8142d5a323c3 /mingling_macros/src | |
| parent | fe1a3ef523ac50611e559cbc445df731cd3d0d19 (diff) | |
Replace unsafe unwrap with unwrap_unchecked in renderer macro
Diffstat (limited to 'mingling_macros/src')
| -rw-r--r-- | mingling_macros/src/renderer.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mingling_macros/src/renderer.rs b/mingling_macros/src/renderer.rs index 4edac88..f700cbf 100644 --- a/mingling_macros/src/renderer.rs +++ b/mingling_macros/src/renderer.rs @@ -112,7 +112,9 @@ pub fn renderer_attr(item: TokenStream) -> TokenStream { #[cfg(feature = "general_renderer")] let general_renderer_entry = quote! { Self::#previous_type => { - let raw = any.restore::<#previous_type>().unwrap(); + // SAFETY: Only types that match will enter this branch for forced conversion, + // and `AnyOutput::new` ensures the type implements serde::Serialize + let raw = unsafe { any.restore::<#previous_type>().unwrap_unchecked() }; let mut r = ::mingling::RenderResult::default(); ::mingling::GeneralRenderer::render(&raw, setting, &mut r)?; Ok(r) |
