Closed kang-sw closed 1 year ago
Heh, that's an interesteen puzzle, see https://github.com/rust-lang/rust/pull/103718.
We might consider doing the same for once cell, once our MSRV allows.
For your specific case, the fix would be
let lazy: Lazy<String, _> = Lazy::new(|| "sd".to_uppercase());
Oh, thanks for your reply. Now it compiles!
Above code returns following error:
In Cargo:
(Can't compile example one neither, which replaces "sd" to captured 'hello')
It seems the compiler should deduce type 'String' from return value of given closure, but it doesn't. Am I doing something wrong?
I'm using rustc 1.63.0 on Windows.