Initial project import

This commit is contained in:
Agila Forge Importer committed 2026-07-13 15:20:32 +00:00
commit 23f2d29e32
11957 files changed
+1754577

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
import io
struct Buf {
pub:
bytes []u8
mut:
i int
}
struct Writ {
pub mut:
bytes []u8
}
fn (mut b Buf) read(mut buf []u8) !int {
if !(b.i < b.bytes.len) {
return io.Eof{}
}
n := copy(mut buf, b.bytes[b.i..])
b.i += n
return n
}
fn (mut w Writ) write(buf []u8) !int {
if buf.len <= 0 {
return error('none')
}
w.bytes << buf
return buf.len
}
fn test_copy() {
mut src := Buf{
bytes: 'abcdefghij'.repeat(10).bytes()
}
mut dst := Writ{
bytes: []u8{}
}
io.cp(mut src, mut dst) or { assert false }
assert dst.bytes == src.bytes
}