Skip to content

Commit

Permalink
Eliminate gen::helper module
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed May 19, 2024
1 parent eacc8ab commit ed54092
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 115 deletions.
11 changes: 10 additions & 1 deletion codegen/src/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn visit(
let Type::Syn(t) = &**t else { unimplemented!() };
let method = method_name(t);
Some(quote! {
crate::gen::helper::fold::vec(#name, f, F::#method)
fold_vec(#name, f, F::#method)
})
}
Type::Punctuated(p) => {
Expand Down Expand Up @@ -242,6 +242,15 @@ pub fn generate(defs: &Definitions) -> Result<()> {
}

#impls

#[cfg(any(feature = "derive", feature = "full"))]
fn fold_vec<T, V, F>(vec: Vec<T>, fold: &mut V, mut f: F) -> Vec<T>
where
V: ?Sized,
F: FnMut(&mut V, T) -> T,
{
vec.into_iter().map(|it| f(fold, it)).collect()
}
},
)?;
Ok(())
Expand Down

0 comments on commit ed54092

Please sign in to comment.