-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo_compile: iterate packages once, not three times #4494
Conversation
What do you think about using map/collect here? That way, we can avoid marking the vector as mut, and this is useful, because the future reader would not have to wonder if the variable is mutated down the line. |
I tried, but ended up getting lifetime errors about let to_builds = specs.iter()
.map(|p| {
p.query(resolve_with_overrides.iter()).and_then(|p| {
packages.get(p).and_then(|p| {
p.manifest().print_teapot(ws.config());
Ok(p)
})
})
})
.collect::<CargoResult<Vec<_>>>()?;
|
The following seems to work for me: let to_builds = specs.iter().map(|p| {
let pkgid = p.query(resolve_with_overrides.iter())?;
let p = packages.get(pkgid)?;
p.manifest().print_teapot(ws.config());
Ok(p)
}).collect::<CargoResult<Vec<_>>>()?; |
Wow, I did not know that one could use the |
It's ok as long as compiler is able to figure out the types. @bors r+ Thanks! |
📌 Commit f490f16 has been approved by |
☀️ Test successful - status-appveyor, status-travis |
I forgot to push this into #4492
r? @matklad