diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-25 12:54:51 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-11-25 12:54:51 +0100 |
commit | dc568083381d2073f0cfcfad8fa58158bd5bf811 (patch) | |
tree | 3c0655dd65c5912a4cbfd02bb4c9738e62074ccf /src/syn_utils.rs | |
parent | 06a384000b0a6c7b657e4f8a9145b3d4357f3d70 (diff) |
refactor: remove unnecessary TypeOrPath type
Diffstat (limited to 'src/syn_utils.rs')
-rw-r--r-- | src/syn_utils.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/syn_utils.rs b/src/syn_utils.rs index 00efee0..369aeb7 100644 --- a/src/syn_utils.rs +++ b/src/syn_utils.rs @@ -32,11 +32,6 @@ pub fn type_arguments_mut<P>( }) } -pub enum TypeOrPath<'a> { - Type(&'a Type), - Path(&'a Path), -} - enum IterTypes<A, B, C, D, E, F> { Single(A), Function(B), @@ -71,13 +66,13 @@ where } } -pub fn iter_path(path: &Path) -> impl Iterator<Item = TypeOrPath> { - iter::once(TypeOrPath::Path(path)).chain(types_in_path(path).flat_map(|t| iter_type(t))) +pub fn iter_path(path: &Path) -> impl Iterator<Item = &Type> { + types_in_path(path).flat_map(|t| iter_type(t)) } -pub fn iter_type<'a>(t: &'a Type) -> Box<dyn Iterator<Item = TypeOrPath<'a>> + 'a> { +pub fn iter_type<'a>(t: &'a Type) -> Box<dyn Iterator<Item = &'a Type> + 'a> { Box::new( - iter::once(TypeOrPath::Type(t)).chain(match t { + iter::once(t).chain(match t { Type::Array(array) => IterTypes::Single(iter_type(&array.elem)), Type::Group(group) => IterTypes::Single(iter_type(&group.elem)), Type::Paren(paren) => IterTypes::Single(iter_type(&paren.elem)), |