Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

for index for indices loop example issue

Open
#53 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
rust
Domain
documentation

Research direction

Start by reproducing the for_idx.rs snippet with the Rust version and compiler output reported in the issue. Review the intended index-loop example and its formatting, then update the example so it matches the supported Rust behavior and compiles without the reported errors.

Written by the indexing model from the issue text.

Description

working with for .. index loop example.

$ rustc --version
rustc 1.12.0-nightly (9316ae515 2016-07-24)
$

fn print_all( all: Vec ){
for i in ..all.len() {
println!("{}: {}", i, all.get(i));
}
}

fn main() {
}
`
the compiler error seen is

for_idx.rs:4:2: 6:3 error: the trait bound std::ops::RangeTo<usize>: std::iter::Iterator is not satisfied [E0277]
for_idx.rs:4 for i in ..all.len() {
^
for_idx.rs:4:2: 6:3 help: run rustc --explain E0277 to see a detailed explanation
for_idx.rs:4:2: 6:3 note: std::ops::RangeTo<usize> is not an iterator; maybe try calling .iter() or a similar method
for_idx.rs:4:2: 6:3 note: required by std::iter::IntoIterator::into_iter
for_idx.rs:5:25: 5:35 error: the trait bound std::option::Option<&i32>: std::fmt::Display is not satisfied [E0277]
for_idx.rs:5 println!("{}: {}", i, all.get(i));
^~~~~~~~~~
:2:27: 2:58 note: in this expansion of format_args!
:3:1: 3:54 note: in this expansion of print! (defined in )
for_idx.rs:5:3: 5:37 note: in this expansion of println! (defined in )
for_idx.rs:5:25: 5:35 help: run rustc --explain E0277 to see a detailed explanation
for_idx.rs:5:25: 5:35 note: std::option::Option<&i32> cannot be formatted with the default formatter; try using :? instead if you are using a format string
for_idx.rs:5:25: 5:35 note: required by std::fmt::Display::fmt
error: aborting due to 2 previous errors

Dominant language
Rust
Stars
3.9k
Forks
297
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nrc/r4cppp

All issues in nrc/r4cppp

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.