extend-fn

Crates.ioextend-fn
lib.rsextend-fn
version1.0.0
created_at2025-04-06 21:40:02.673356+00
updated_at2025-04-06 21:40:02.673356+00
descriptionUse arbitrary FnMut when something that must implement Extend is needed
homepagehttps://gitlab.com/infomorphic-matti/extend-fn/
repositoryhttps://gitlab.com/infomorphic-matti/extend-fn/
max_upload_size
id1623416
size21,003
Matti (infomorphic-matti)

documentation

https://docs.rs/extend-fn

README

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());
Commit count: 3

cargo fmt