Skip to content

Commit

Permalink
use syn-path utility crate
Browse files Browse the repository at this point in the history
  • Loading branch information
msrd0 committed Jul 11, 2022
1 parent 96d8070 commit e273fc0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
1 change: 1 addition & 0 deletions derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ regex = []
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "1.0", features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"], default-features = false }
syn-path = "1"
1 change: 1 addition & 0 deletions derive/src/form_data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use syn::{
TraitBound, TraitBoundModifier, Type, TypeParamBound, TypePath, WhereClause,
WherePredicate
};
use syn_path::path;

mod builder;
use builder::FormDataBuilder;
Expand Down
25 changes: 0 additions & 25 deletions derive/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
use proc_macro2::Span;
use syn::{Error, Path};

macro_rules! path {
(:: $($segment:ident)::*) => {
path!(@private Some(Default::default()), $($segment),*)
};
($($segment:ident)::*) => {
path!(@private None, $($segment),*)
};
(@private $leading_colon:expr, $($segment:ident),*) => {
{
#[allow(unused_mut)]
let mut segments: ::syn::punctuated::Punctuated<::syn::PathSegment, _> = Default::default();
$(
segments.push(::syn::PathSegment {
ident: ::proc_macro2::Ident::new(stringify!($segment), ::proc_macro2::Span::call_site()),
arguments: Default::default()
});
)*
::syn::Path {
leading_colon: $leading_colon,
segments
}
}
};
}

pub(crate) trait CollectToResult {
type Item;

Expand Down

0 comments on commit e273fc0

Please sign in to comment.