sycamore_router_macro/lib.rs
1//! Macro support for the `sycamore-router` crate.
2
3#![deny(missing_debug_implementations)]
4#![warn(missing_docs)]
5
6mod parser;
7mod route;
8
9use proc_macro::TokenStream;
10use syn::{parse_macro_input, DeriveInput};
11
12/// The `Route` procedural macro.
13///
14/// This macro derives the `Route` trait for the given `enum`.
15#[proc_macro_derive(Route, attributes(to, not_found))]
16pub fn route(input: TokenStream) -> TokenStream {
17 let input = parse_macro_input!(input as DeriveInput);
18
19 route::route_impl(input)
20 .unwrap_or_else(|err| err.to_compile_error())
21 .into()
22}