Hey Rustaceans! Got an easy question? Ask here (11/2020)!

Is there an RFC to allow this?

let v = if flag {
    Vec::<i32>::new()
} else {
    Vec::<f64>::new()
};

Or what if I had a hypothetical Container trait which Vec implements and I'd like to write the following? I know traits aren't really for use in type specs outside of 'impl SomeTrait`, but I had the urge to write something like below and been asking myself if I'm missing a nightly feature.

let v: Container = if flag {
    Vec::<i32>::new()
} else {
    Vec::<f64>::new()
};

In this second feature, I'd expect to only call Container's functions from the trait while disallowing access to Vec's features. This reminds me of the idiom of SomethingExt traits and that makes me wonder if I'm missing another convention here as well.

/r/rust Thread