nandi/rustnimpublic Fork 0
d4592812fae6b652d94be442f5b3a408d3ab21b6
Commits
Clone
git clone https://git.rickub.com/nandi/rustnim.git
git clone ssh://git@rickub.com/nandi/rustnim.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Add the differential test runner, and a lowering to measure with it 8ac32af · on d4592812fae6b652d94be442f5b3a408d3ab21b6 · nandithebull · 11h ago
011-slices-and-vec.rs · 19 lines · 365 BRust Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
fn sum(xs: &[i32]) -> i32 {
    let mut t: i32 = 0;
    for x in xs {
        t += x;
    }
    t
}

fn main() {
    let v: Vec<i32> = vec![1, 2, 3, 4];
    println!("{}", sum(&v));
    println!("{}", v.len());
    println!("{}", v[2]);
    println!("{:?}", v);
    let mut w: Vec<i32> = vec![];
    w.push(9);
    w.push(8);
    println!("{:?} {}", w, w.len());
}