Closed pitdicker closed 4 years ago
Again an experiment, to see the effects of https://github.com/rust-lang/rfcs/pull/2788#discussion_r342484357.
This way of adding poisoning to OnceCell and Lazy seems not all that invasive to me, however it is a large breaking change.
OnceCell
Lazy
The compiler is usually very helpful with its error message:
--> tests/test.rs:211:19 | 211 | c.get_or_init(|| 92); | ^^^^^^^^^^^ -- takes 0 arguments | | | expected closure that takes 1 argument | help: consider changing the closure to take and ignore the expected argument | 211 | c.get_or_init(|_| 92); |
Except when there are manual dereferences of a Lazy:
error[E0614]: type `once_cell::sync::Lazy<_, [closure@tests/test.rs:369:27: 372:10 called:_]>` cannot be dereferenced --> tests/test.rs:378:25 | 378 | let y = *x - 30; |
I only did the sync types for now, and also didn't do the parking_lot implementation properly.
sync
parking_lot
Again an experiment, to see the effects of https://github.com/rust-lang/rfcs/pull/2788#discussion_r342484357.
This way of adding poisoning to
OnceCell
andLazy
seems not all that invasive to me, however it is a large breaking change.The compiler is usually very helpful with its error message:
Except when there are manual dereferences of a
Lazy
:I only did the
sync
types for now, and also didn't do theparking_lot
implementation properly.