Closed
Description
Code
fn main() {
let v = vec![1,2,3,4];
for pair in v.chunk(2) {
println!("{}, {}", pair[0], pair[1]);
}
}
Current output
error[E0599]: no method named `chunk` found for struct `Vec<{integer}>` in the current scope
--> src/main.rs:3:19
|
3 | for pair in v.chunk(2) {
| ^^^^^ help: there is a method with a similar name: `as_chunks`
For more information about this error, try `rustc --explain E0599`.
Desired output
error[E0599]: no method named `chunk` found for struct `Vec<{integer}>` in the current scope
--> src/main.rs:3:19
|
3 | for pair in v.chunk(2) {
| ^^^^^ help: there is a method with a similar name: `chunks`
For more information about this error, try `rustc --explain E0599`.
Rationale and extra context
It would be more helpful to suggest the chunks
method for the typo rather than a nightly-only symbol which isn't actually available.
- Following the suggestion doesn't work.
- The
chunks()
method is actually available on astd::slice
. - The
chunks()
method has been stable since 1.0.0. - I had trouble noticing the difference between
.chunk()
and.chuncks()
and could have used the compiler's help.
Other cases
No response
Anything else?
Reproduced with 1.68.0 stable and 1.70 nightly.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: A structured suggestion resulting in incorrect code.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.