rep_move 0.1.0

Replicating iterators: N-1 clones plus one final move of the original value
Documentation
  • Coverage
  • 94.74%
    18 out of 19 items documented5 out of 19 items with examples
  • Size
  • Source code size: 40.0 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.1 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • wisdgod/rep_move
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • wisdgod

rep_move

crates.io docs.rs

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 rep_move::RepMove;

let original = vec![1, 2, 3];
let copies: Vec<_> = RepMove::new(original, Vec::clone, 4).collect();
// 3 heap allocations instead of 4 — the last one was moved for free.
assert_eq!(copies.len(), 4);

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 constructors const fn and Replicator a const trait. Requires a nightly compiler.

License

Licensed under the MIT license.