run_once 0.1.1

Runs code in rust once, from a closure
Documentation
  • Coverage
  • 0%
    0 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 1.93 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 264.55 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • toastxc/run_once
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • toastxc

Run Once

Code inside the closure (of the same value*) will only run once.

r.run_once(1, || {
  // do stuff here!
});

Two closures of different values will both run once.

r.run_once(1, || {});
r.run_once(2, || {});

Example

fn test() {
  let mut data = RunOnce::default();
  let mut value = 0;

  for _ in 0..5 {
    data.run_once(1, || {
      value += 1;
    });
  }
  assert_eq!(value, 1);
}