Impl trait in let bindings
You can also use impl Trait
in the type of a local variable:
#![allow(unused)] fn main() { let x: impl Clone = 22_i32; }
This is equivalent to introducing a type alias impl trait with the scope of the enclosing function:
#![allow(unused)] fn main() { type X = impl Clone; let x: X = 22_i32; }