Repository: typst/typst
File: crates/typst-macros/src/lib.rs (Rust)

Code before:
/// ```ignore
/// const EMOJI: &[(&str, Symbol)] = symbols! {
///     // A plain symbol without modifiers.
///     abacus: '🧮',
///
///     // A symbol with a modifierless default and one modifier.
///     alien: ['👽', monster: '👾'],
///
///     // A symbol where each variant has a modifier. The first one will be
///     // the default.
///     clock: [one: '🕐', two: '🕑', ...],
///
///     // A callable symbol without modifiers.
///     breve: #[call(crate::math::breve)] '˘',
///
///     // A callable symbol with a modifierless default and one modifier.
///     acute: [
///         #[call(crate::math::acute)] '´',
///         double: '˝',
///     ],
///
///     // A callable symbol where each variant has a modifier.
///     arrow: [
///         #[call(crate::math::arrow)] r: '→',
///         r.long.bar: '⟼',
///         #[call(crate::math::arrow)] l: '←',
///         l.long.bar: '⟻',
///     ],
///
///     // A callable symbol, with a modifierless default function, where each
///     // variant has a modifier.
///     floor: [
///         #[call(crate::math::floor)] self,
///         l: '⌊',
///         r: '⌋',
///     ],
/// }
/// ```
///
/// _Note:_ While this could use `macro_rules!` instead of a proc-macro, it was
/// horribly slow in rust-analyzer. The underlying cause might be
/// [this issue](https://github.com/rust-lang/rust-analyzer/issues/11108).
#[proc_macro]
pub fn symbols(stream: BoundaryStream) -> BoundaryStream {
    symbols::symbols(stream.into())
        .unwrap_or_else(|err| err.to_compile_error())
        .into()
}

/// Times function invocations.
///

Review comment (suggestion):
```suggestion
///         #[call(crate::math::arrow_l)] l: '←',
```

Code after:
/// ```ignore
/// const EMOJI: &[(&str, Symbol)] = symbols! {
///     // A plain symbol without modifiers.
///     abacus: '🧮',
///
///     // A symbol with a modifierless default and one modifier.
///     alien: ['👽', monster: '👾'],
///
///     // A symbol where each variant has a modifier. The first one will be
///     // the default.
///     clock: [one: '🕐', two: '🕑', ...],
///
///     // A callable symbol without modifiers.
///     breve: #[call(crate::math::breve)] '˘',
///
///     // A callable symbol with a modifierless default and one modifier.
///     acute: [
///         #[call(crate::math::acute)] '´',
///         double: '˝',
///     ],
///
///     // A callable symbol where each variant has a modifier.
///     arrow: [
///         #[call(crate::math::arrow)] r: '→',
///         r.long.bar: '⟼',
///         #[call(crate::math::arrow_l)] l: '←',
///         l.long.bar: '⟻',
///     ],
/// }
/// ```
///
/// _Note:_ While this could use `macro_rules!` instead of a proc-macro, it was
/// horribly slow in rust-analyzer. The underlying cause might be
/// [this issue](https://github.com/rust-lang/rust-analyzer/issues/11108).
#[proc_macro]
pub fn symbols(stream: BoundaryStream) -> BoundaryStream {
    symbols::symbols(stream.into())
        .unwrap_or_else(|err| err.to_compile_error())
        .into()
}

/// Times function invocations.
///
/// When tracing is enabled in the typst-cli, this macro will record the
/// invocations of the function and store them in a global map. The map can be
/// accessed through the `typst_trace::RECORDER` static.
///
/// You can also specify the span of the function invocation:
/// - `#[time(span = ..)]` to record the span, which will be used for the
///   `EventKey`.
///