lazytry 0.1.0

Providing failable lazy values
Documentation
  • Coverage
  • 22.22%
    4 out of 18 items documented0 out of 10 items with examples
  • Size
  • Source code size: 6.82 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.15 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • snylonue/lazytry
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • snylonue

lazytry

lazytry aims for lazy data evaluation which may fail.

use lazytry::unsync::LazyTry;

let lazy: LazyTry<i32, _> = LazyTry::new(|| "1".parse());

assert_eq!(lazy.force().unwrap(), &1);
assert_eq!(lazy.force().unwrap(), &1);
use lazytry::unsync::LazyTryFn;
use std::num::{IntErrorKind, ParseIntError};

let lazy: LazyTryFn<i32, ParseIntError> = LazyTry::new(|| "a".parse());

assert_eq!(
    *lazy.force().unwrap_err().into_err().unwrap().kind(),
    IntErrorKind::InvalidDigit
);

The current code is quite experimental, including unproved use of unsafe (impl Sync), lack of documentation and a weird and incompleted api.