#extend #iterator #function #no-alloc

no-std extend-fn

Use arbitrary FnMut when something that must implement Extend is needed

1 stable release

Uses new Rust 2024

new 1.0.0 Apr 6, 2025

#1221 in Rust patterns

MPL-2.0 license

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());

No runtime deps