Type inference for todo!() works if it is the sole element returned from a map closure, but breaks as soon as it is placed inside a tuple. playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1cfae6d57f44f603fa2eb258d332c7ab
I tried this code:
fn foo(_: Vec<(u32, String)>) {}
fn main() {
foo((0..6).into_iter().map(|i| (i, todo!())).collect())
}
I expected to see this happen: compiles
Instead, this happened: compile error
error[E0277]: a value of type `Vec<(u32, String)>` cannot be built from an iterator over elements of type `({integer}, !)`
--> src/main.rs:5:50
|
5 | foo((0..6).into_iter().map(|i| (i, todo!())).collect())
| --- ^^^^^^^ value of type `Vec<(u32, String)>` cannot be built from `std::iter::Iterator<Item=({integer}, !)>`
| |
| required by a bound introduced by this call
Meta
I checked "nightly" on the playground and the same compile error happens.
Type inference for
todo!()works if it is the sole element returned from a map closure, but breaks as soon as it is placed inside a tuple. playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1cfae6d57f44f603fa2eb258d332c7abI tried this code:
I expected to see this happen: compiles
Instead, this happened: compile error
Meta
I checked "nightly" on the playground and the same compile error happens.