Skip to content

Commit ed54092

Browse files
committed
Eliminate gen::helper module
1 parent eacc8ab commit ed54092

File tree

4 files changed

+117
-115
lines changed

4 files changed

+117
-115
lines changed

codegen/src/fold.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn visit(
3434
let Type::Syn(t) = &**t else { unimplemented!() };
3535
let method = method_name(t);
3636
Some(quote! {
37-
crate::gen::helper::fold::vec(#name, f, F::#method)
37+
fold_vec(#name, f, F::#method)
3838
})
3939
}
4040
Type::Punctuated(p) => {
@@ -242,6 +242,15 @@ pub fn generate(defs: &Definitions) -> Result<()> {
242242
}
243243

244244
#impls
245+
246+
#[cfg(any(feature = "derive", feature = "full"))]
247+
fn fold_vec<T, V, F>(vec: Vec<T>, fold: &mut V, mut f: F) -> Vec<T>
248+
where
249+
V: ?Sized,
250+
F: FnMut(&mut V, T) -> T,
251+
{
252+
vec.into_iter().map(|it| f(fold, it)).collect()
253+
}
245254
},
246255
)?;
247256
Ok(())

0 commit comments

Comments
 (0)