rust-lang/rust-clippy

Add utils helper for filtering out type/lifetime parameters on generics

Open

#3787 opened on Feb 19, 2019

View on GitHub
 (4 comments) (0 reactions) (0 assignees)Rust (10,406 stars) (1,391 forks)batch import
C-enhancementgood first issue

Description

See https://github.com/rust-lang/rust-clippy/pull/3786/files , we have a lot of code that does something like params.args.iter().filter_map(|arg| match arg { GenericArg::Lifetime(lt) => Some(lt), _ => None }

We should probably have a helper function that returns an iterator for these, placed in utils. Probably something like:

fn types_of_generics(generics: &Generics) -> impl Iterator<Type> {...}
fn lifetimes_of_generics(generics: &Generics) -> impl Iterator<Lifetime> {...}

Contributor guide