mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 23:52:31 +00:00
378d3e4403
Changed container and initializer syntax * <container> { ... } -> <container> . { ... } * <exrp> { ... } -> <expr> . { ...}
18 lines
397 B
Zig
18 lines
397 B
Zig
const assert = @import("std").debug.assert;
|
|
|
|
fn get_foo() fn (*u8) usize {
|
|
comptime {
|
|
return struct.{
|
|
fn func(ptr: *u8) usize {
|
|
var u = @ptrToInt(ptr);
|
|
return u;
|
|
}
|
|
}.func;
|
|
}
|
|
}
|
|
|
|
test "define a function in an anonymous struct in comptime" {
|
|
const foo = get_foo();
|
|
assert(foo(@intToPtr(*u8, 12345)) == 12345);
|
|
}
|