diff options
| -rw-r--r-- | mingling/Cargo.lock | 6 | ||||
| -rw-r--r-- | mingling/Cargo.toml | 10 | ||||
| -rw-r--r-- | mingling_core/Cargo.lock | 2 | ||||
| -rw-r--r-- | mingling_core/Cargo.toml | 2 | ||||
| -rw-r--r-- | mingling_core/src/program.rs | 8 |
5 files changed, 16 insertions, 12 deletions
diff --git a/mingling/Cargo.lock b/mingling/Cargo.lock index 01c0292..df4d336 100644 --- a/mingling/Cargo.lock +++ b/mingling/Cargo.lock @@ -27,9 +27,7 @@ dependencies = [ [[package]] name = "mingling_core" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e335faaa96891c3fd13fa497ac1537902367da74933e43ecb39fe8db6060464" +version = "0.1.2" dependencies = [ "just_fmt", "serde", @@ -40,8 +38,6 @@ dependencies = [ [[package]] name = "mingling_macros" version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f1f57fd20f1072939938b779684534d566d2d81104a43a32bf06a377e72bee9" dependencies = [ "just_fmt", "once_cell", diff --git a/mingling/Cargo.toml b/mingling/Cargo.toml index 8a56278..d51c58e 100644 --- a/mingling/Cargo.toml +++ b/mingling/Cargo.toml @@ -16,12 +16,16 @@ mingling = { path = ".", features = ["full"] } [features] default = ["mingling_core/default"] full = ["mingling_core/full", "general_renderer", "parser"] -general_renderer = ["mingling_core/general_renderer", "dep:serde", "mingling_macros/serde"] +general_renderer = [ + "mingling_core/general_renderer", + "dep:serde", + "mingling_macros/serde", +] parser = ["dep:size"] [dependencies] -mingling_core = { version = "0.1.1", default-features = false } -mingling_macros = { version = "0.1.1", default-features = false } +mingling_core = { path = "../mingling_core", default-features = false } +mingling_macros = { path = "../mingling_macros", default-features = false } serde = { version = "1.0", features = ["derive"], optional = true } size = { version = "0.5", optional = true } diff --git a/mingling_core/Cargo.lock b/mingling_core/Cargo.lock index 070d244..5def9e6 100644 --- a/mingling_core/Cargo.lock +++ b/mingling_core/Cargo.lock @@ -16,7 +16,7 @@ checksum = "5454cda0d57db59778608d7a47bff5b16c6705598265869fb052b657f66cf05e" [[package]] name = "mingling_core" -version = "0.1.1" +version = "0.1.2" dependencies = [ "just_fmt", "serde", diff --git a/mingling_core/Cargo.toml b/mingling_core/Cargo.toml index c642c70..40b4c41 100644 --- a/mingling_core/Cargo.toml +++ b/mingling_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mingling_core" -version = "0.1.1" +version = "0.1.2" edition = "2024" license = "MIT OR Apache-2.0" description = "Core of the mingling library" 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) } |
