Cranpose Macros
Procedural macros that power the Cranpose declarative syntax.
When to Use
You will rarely interact with this crate directly; it is re-exported by cranpose. Identifying how the #[composable] macro transforms your code is useful for debugging and understanding performance characteristics.
Key Concepts
#[composable]: This attribute macro transforms a standard Rust function into aComposablefunction. It injects a hiddenComposerparameter and wraps the function body in a uniquely identified group.- Skipping: The macro generates code to compare current arguments with previous arguments. If they haven't changed, the function body execution is skipped during recomposition, significantly improving performance.
- Naming: Composables are CamelCase functions, and the macro allows that name on the function it emits, so a file of composables needs no
#![allow(non_snake_case)].
Transformation Example
Conceptual expansion of what #[composable] does:
// Source
// Generated (Conceptual)