nandi/rustnimpublic Fork 0
3d4a7d283b83d3a5305dfc6654c290bd4ee162ae
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.

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