Closed
Description
Given the following code: https://play.rust-lang.org/?version=beta&mode=debug&edition=2018&gist=965472aeea871e8f49d3decac84abe64
fn get_slice() -> &'static [i32] {
&[1, 2, 3, 4]
}
fn main() {
let sqsum = get_slice().map(|i| i * i).sum();
}
The current output is:
error [E0599]: the method `map` exists for reference `&'static [i32]`, but its trait bounds were not satisfied
--> src/main.rs:6:29
|
6 | let sqsum = get_slice().map(|i| i * i).sum();
| ^^^ method cannot be called on `&'static [i32]` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`&'static [i32]: Iterator`
which is required by `&mut &'static [i32]: Iterator`
`[i32]: Iterator`
which is required by `&mut [i32]: Iterator`
Ideally the output should at least mention that .iter()
exists on slices
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.Relevant to the compiler team, which will review and decide on the PR/issue.