Basic Labeling - Rust

⚓ Rust    📅 2026-03-12    👤 surdeus    👁️ 5      

surdeus

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Basic Labeling - Rust
fn main() {
    let s = [
    [5, 6, 7],
    [8, 9, 10],
    [21, 15, 32]
    ];
    let mut elements_searched = 0;
    let target_value = 10;
    'outer: for i in 0..=2 {
        for j in 0..=2 {
            elements_searched += 1;
            if s[i][j] == target_value {
                break 'outer;
            }
        }
    }
    println!("Elementos pesquisados: {elements_searched}");
}

(Playground)

Output:

Elementos pesquisados: 6

Errors:

   Compiling playground v0.0.1 (/playground)
    Finished `release` profile [optimized] target(s) in 0.47s
     Running `target/release/playground`

1 post - 1 participant

Read full topic

🏷️ Rust_feed