Add `const` and `unsafe` block suport to `bsn!` macro (#24336)
# Objective
Closes #24121
## Solution
Add `const`, `unsafe` and `async` block support to bsn expressions.
## Testing
I've added a compile test for `const` and `unsafe` blocks. I couldn't
figure out how to test or even use the async blocks. The macro needs to
construct a struct that holds a future, but `async` blocks produce
voldemort (unnameable) types. Using `Box<dyn Future>` fixes this problem
but then you run into the problem that the struct needs to be clone-able
and have a default value. `async` block futures have neither of those
properties.
---
## Showcase
The `bsn!` macro now supports `const` and `unsafe` blocks.
```rust,
fn friendly(people: &[&'static str]) -> impl Scene {
bsn! {
Friend {
name: const {"John"}
// SAFETY: Jesus take the wheel
father: unsafe {people.get_unchecked(0)}
}
}
}
``` L
loreball committed
ebd5f4335812909d6a0bd173d3177713d09e7e9c
Parent: ba149c1
Committed by GitHub <noreply@github.com>
on 5/20/2026, 8:22:48 PM