1#![doc = include_str!("../README.md")]
2
3mod lazy_into;
4
5pub use lazy_into::{LazyInto, LazyIntoFn};
6
7#[cfg(test)]
8mod tests {
9 use super::{LazyInto, LazyIntoFn};
10
11 #[test]
12 fn test_input_debug() {
13 let a = LazyInto::new(42, |n| n as f64 * 2.0);
14 let s = "Input(42)";
15
16 assert_eq!(format!("{a:?}"), s);
17
18 a.force();
19 assert_ne!(format!("{a:?}"), s);
20 }
21
22 #[test]
23 fn test_output_debug() {
24 let a = LazyInto::new(42, |n| n as f64 * 2.0);
25 a.force();
26
27 assert_eq!(format!("{a:?}"), "Output(84.0)");
28 }
29
30 #[test]
31 fn test_poison_debug() {
32 use std::panic::{catch_unwind, AssertUnwindSafe};
33
34 let a: LazyIntoFn<i32, f64> = LazyInto::new(42, |_| panic!("oops"));
35
36 let _ = catch_unwind(AssertUnwindSafe(|| {
37 a.force();
38 }));
39
40 assert_eq!(format!("{a:?}"), "Poisoned");
41 }
42}