Merge branch 'master' into feat/basic-enum-support

This commit is contained in:
Stephan Wolski
2018-07-11 15:34:00 -04:00
committed by GitHub
12 changed files with 583 additions and 38 deletions

View File

@ -35,6 +35,23 @@ pub fn raw_ident(name: &str) -> Ident {
/// Create a path type from the given segments. For example an iterator yielding
/// the idents `[foo, bar, baz]` will result in the path type `foo::bar::baz`.
pub fn simple_path_ty<I>(segments: I) -> syn::Type
where
I: IntoIterator<Item = Ident>,
{
path_ty(false, segments)
}
/// Create a global path type from the given segments. For example an iterator
/// yielding the idents `[foo, bar, baz]` will result in the path type
/// `::foo::bar::baz`.
pub fn leading_colon_path_ty<I>(segments: I) -> syn::Type
where
I: IntoIterator<Item = Ident>,
{
path_ty(true, segments)
}
fn path_ty<I>(leading_colon: bool, segments: I) -> syn::Type
where
I: IntoIterator<Item = Ident>,
{
@ -49,7 +66,11 @@ where
syn::TypePath {
qself: None,
path: syn::Path {
leading_colon: None,
leading_colon: if leading_colon {
Some(Default::default())
} else {
None
},
segments: syn::punctuated::Punctuated::from_iter(segments),
},
}.into()