| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | const assert = @import("std").debug.assert; | 1 | const assert = @import("std").debug.assert; |
| | 2 | const mem = @import("std").mem; |
| 2 | | 3 | |
| 3 | const x = @intToPtr(&i32, 0x1000)[0..0x500]; | 4 | const x = @intToPtr(&i32, 0x1000)[0..0x500]; |
| 4 | const y = x[0x100..]; | 5 | const y = x[0x100..]; |
| ... | @@ -15,3 +16,12 @@ test "slice child property" { | ... | @@ -15,3 +16,12 @@ test "slice child property" { |
| 15 | var slice = array[0..]; | 16 | var slice = array[0..]; |
| 16 | assert(@typeOf(slice).Child == i32); | 17 | assert(@typeOf(slice).Child == i32); |
| 17 | } | 18 | } |
| | 19 | |
| | 20 | test "debug safety lets us slice from len..len" { |
| | 21 | var an_array = []u8{1, 2, 3}; |
| | 22 | assert(mem.eql(u8, sliceFromLenToLen(an_array[0..], 3, 3), "")); |
| | 23 | } |
| | 24 | |
| | 25 | fn sliceFromLenToLen(a_slice: []u8, start: usize, end: usize) -> []u8 { |
| | 26 | return a_slice[start..end]; |
| | 27 | } |