~lthms/typed-urls

c6c6be84b757fb0da15cb08478b418cc44680d40 — Thomas Letan 1 year, 4 days ago b6e74d6
Clean-up the code
4 files changed, 6 insertions(+), 7 deletions(-)

M routes-derive/Cargo.toml
M routes-derive/src/lib.rs
M src/lib.rs
M tests/simple.rs
M routes-derive/Cargo.toml => routes-derive/Cargo.toml +1 -2
@@ 9,5 9,4 @@ proc-macro = true

[dependencies]
syn = "1.0"
quote = "1.0"
serde_json = "*"
\ No newline at end of file
quote = "1.0"
\ No newline at end of file

M routes-derive/src/lib.rs => routes-derive/src/lib.rs +3 -3
@@ 12,7 12,7 @@ use syn::{
    MetaNameValue, Type, Variant,
};

#[proc_macro_derive(Router, attributes(routefmt))]
#[proc_macro_derive(Routes, attributes(routefmt))]
pub fn derive_routes_main(input : TokenStream) -> TokenStream {
    let ast : DeriveInput = parse_macro_input!(input as DeriveInput);



@@ 192,7 192,7 @@ fn derive_routes_boilerplate(ast : &DeriveInput) -> Quote {

    quote! {
        use std::iter::Iterator;
        use routes::Routes;
        use routes::Routing;

        #enum_to_string
        #route_enum


@@ 281,7 281,7 @@ fn derive_route_routes_impl(
    let to_url_impl = derive_route_to_url(name, enum_ast, tf, uf);

    quote! {
        impl Routes for Route {
        impl Routing for Route {
            type Url = #name;

            #to_string_impl

M src/lib.rs => src/lib.rs +1 -1
@@ 3,7 3,7 @@ use std::slice::Iter;

use serde_json::Value;

pub trait Routes {
pub trait Routing {
    type Url;

    fn enumerate() -> Iter<'static, Self>

M tests/simple.rs => tests/simple.rs +1 -1
@@ 1,7 1,7 @@
#[macro_use]
extern crate routes_derive;

#[derive(Router)]
#[derive(Routes)]
pub enum Url {
    #[routefmt = "/worlds"]
    Worlds,