cli: add bounded std copy/search and checked arithmetic
This commit is contained in:
36 files changed
+1533
-7
No files matched your search
@@ -0,0 +1,19 @@
|
||||
// expect: run
|
||||
// result: 2
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.4
|
||||
module test.bounded_offset
|
||||
import std.bytes;
|
||||
|
||||
fn locate(data: slice<u8>) -> usize
|
||||
effects []
|
||||
{
|
||||
match std.bytes.find_slice(ref data[2..data.len], b"ab") {
|
||||
std.bytes.FindResult::found(index) => { return index; }
|
||||
std.bytes.FindResult::not_found => { trap; }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> usize
|
||||
effects []
|
||||
{ return locate(b"xxzzab"); }
|
||||
Reference in new issue
Block a user