Sha256: a9430ee1c0fc9fee2bcc0db6b45105b5a3edef1dcc3a6c04e5865efd57abc114

Contents?: true

Size: 465 Bytes

Versions: 396

Compression:

Stored size: 465 Bytes

Contents

pub fn raindrops(n: usize) -> String {
    let is_pling = |n| n % 3 == 0;
    let is_plang = |n| n % 5 == 0;
    let is_plong = |n| n % 7 == 0;
    let mut drops = String::new();
    if is_pling(n) {
        drops.push_str("Pling");
    }
    if is_plang(n) {
        drops.push_str("Plang");
    }
    if is_plong(n) {
        drops.push_str("Plong");
    }
    if drops.is_empty() {
        let s = format!("{}", n);
        drops.push_str(&s);
    }
    drops
}

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.179 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.178 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.177 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.176 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.175 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.174 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.173 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.172 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.171 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.170 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.169 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.167 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.166 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.165 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.164 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.163 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.162 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.161 tracks/rust/exercises/raindrops/example.rs
trackler-2.2.1.160 tracks/rust/exercises/raindrops/example.rs