1 stable release
Uses new Rust 2024
new 1.0.0 | Apr 6, 2025 |
---|
#1221 in Rust patterns
8KB
extend-fn
Simple no-alloc
library that allows using any arbitrary FnMut
that takes a single value, in a place where types implementing Extend
are needed.
use extend_fn::ExtendUsing;
let initial = [3, 8, 2usize];
let mut result = 0usize;
let mut extender = ExtendUsing::new(|value: usize| result += value);
extender.extend(initial.iter().copied());
assert_eq!(result, initial.into_iter().sum());