24 lines
620 B
Rust
24 lines
620 B
Rust
// expect: run
|
|
// result: [5,5,5,165]
|
|
// equivalent: std/bounded_copy.air
|
|
// phase: 6
|
|
// spec: docs/spec/16-standard-library.md §2.4
|
|
module test.bounded_copy
|
|
import std.bytes;
|
|
|
|
fn main() -> [u8; 4]
|
|
effects []
|
|
{
|
|
let src: [u8; 3] = [5; 3];
|
|
var dst: [u8; 4] = [165; 4];
|
|
match std.bytes.copy(mut dst[0..2], ref src) {
|
|
std.bytes.WriteResult::ok => { trap; }
|
|
std.bytes.WriteResult::short_output => { assert(dst[0] == 165); }
|
|
}
|
|
match std.bytes.copy(mut dst, ref src) {
|
|
std.bytes.WriteResult::ok => {}
|
|
std.bytes.WriteResult::short_output => { trap; }
|
|
}
|
|
return dst;
|
|
}
|