try-push 1.0.2

A trait for attempting potentially expensive actions
Documentation
  • Coverage
  • 28.57%
    2 out of 7 items documented0 out of 4 items with examples
  • Size
  • Source code size: 4.65 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.38 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Nokel81/try-push
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Nokel81

This crate is useful for preventing expensive actions from taking place while adding elements to collections. It exports a single trait, TryPush and has implementations for both Vec<T> and VecDeque<T> from the standard library.

Examples:

use try_push::*;

let mut vec = Vec::with_capacity(4);
vec.push(1);
vec.push(2);
vec.push(3);
vec.push(4); // won't reallocate
// vec.push(5); // will reallocate

assert_eq!(vec.try_push(5), Element::NotAdded(5));