1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Test: Array indexing with int type
// Bug: Windjammer's 'int' maps to i64, but Rust needs usize for indexing
// This should compile without errors
fn get_element(arr: Vec<i32>, index: int) -> i32 {
return arr[index]
}
fn get_element_with_cast(arr: Vec<i32>, index: i64) -> i32 {
// Explicit cast should also work
return arr[index as int]
}
fn test_array_access() -> i32 {
let numbers = vec![10, 20, 30, 40, 50]
let idx = 2
return numbers[idx]
}