rep_move
Replicating iterators: build N values from one source with N−1 clones — the
original is moved out on the final iteration, saving one clone for
heap-backed types like Vec, String, or Arc-wrapped data.
#![no_std], zero dependencies.
Example
use RepMove;
let original = vec!;
let copies: = new.collect;
// 3 heap allocations instead of 4 — the last one was moved for free.
assert_eq!;
Types
| Type | Output | Length known up front? |
|---|---|---|
RepMove |
T |
Yes — ExactSizeIterator |
RepMap |
U |
Yes — ExactSizeIterator |
DynamicRepMove |
T |
No — the closure controls the count |
DynamicRepMap |
U |
No — the closure controls the count |
The *RepMap types are asymmetric: the first N−1 items are built from &T
and the final one consumes T, both producing some other type U — the
last conversion reuses the source's resources instead of cloning them.
Full API documentation lives in the source docs: https://docs.rs/rep_move
Feature flags
nightly(disabled by default) — makes the constructorsconst fnandReplicatoraconst trait. Requires a nightly compiler.
License
Licensed under the MIT license.