Is it possible to imply Copy for Option::None?

There's already a plan for your scenario. It looks like this:

pub fn demo() -> [Option<String>; 100] {
    [const { None }; 100]
}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=7baacd534e95411c7987bdce99b562ba

Hopefully it won't be too long until it stabilizes.

EDIT months later: Stabilization is proposed! https://github.com/rust-lang/rust/pull/104087#issuecomment-1315946122

3 Likes