1 use core::iter::FusedIterator;
2 use rustc_ast::visit::{walk_attribute, walk_expr, Visitor};
3 use rustc_ast::{Attribute, Expr};
4 use rustc_span::symbol::Ident;
6 pub struct IdentIter(std::vec::IntoIter<Ident>);
8 impl Iterator for IdentIter {
11 fn next(&mut self) -> Option<Self::Item> {
16 impl FusedIterator for IdentIter {}
18 impl From<&Expr> for IdentIter {
19 fn from(expr: &Expr) -> Self {
20 let mut visitor = IdentCollector::default();
22 walk_expr(&mut visitor, expr);
24 IdentIter(visitor.0.into_iter())
28 impl From<&Attribute> for IdentIter {
29 fn from(attr: &Attribute) -> Self {
30 let mut visitor = IdentCollector::default();
32 walk_attribute(&mut visitor, attr);
34 IdentIter(visitor.0.into_iter())
39 struct IdentCollector(Vec<Ident>);
41 impl Visitor<'_> for IdentCollector {
42 fn visit_ident(&mut self, ident: Ident) {