This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const warn = @import("std").debug.warn; | |
| test "run" { | |
| warn("\n"); | |
| // allocates 100 bytes of memory. 'len' refers to this sized memory, and so | |
| // will always be the same length. | |
| var arr: [100]u8 = undefined; | |
| warn("\n{}, {}", arr.len, u16(@sizeOf([100]u8))); // 100, 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const warn = @import("std").debug.warn; | |
| test "immutable slices?" { | |
| var array = "hi mom"; | |
| const slice = array[0..2]; | |
| warn("\n{}\n", array); // hi mom | |
| warn("{}\n", slice); // hi | |
| // ok, it's `var` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/std/c/darwin.zig b/std/c/darwin.zig | |
| index 7ce29b50..49999b42 100644 | |
| --- a/std/c/darwin.zig | |
| +++ b/std/c/darwin.zig | |
| @@ -6,25 +6,25 @@ pub const _errno = __error; | |
| /// Renamed to Stat to not conflict with the stat function. | |
| pub const Stat = extern struct { | |
| - dev: u32, | |
| - mode: u16, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/std/c/darwin.zig b/std/c/darwin.zig | |
| index 7ce29b50..92ae2a2a 100644 | |
| --- a/std/c/darwin.zig | |
| +++ b/std/c/darwin.zig | |
| @@ -6,25 +6,26 @@ pub const _errno = __error; | |
| /// Renamed to Stat to not conflict with the stat function. | |
| pub const Stat = extern struct { | |
| - dev: u32, | |
| - mode: u16, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/std/c/darwin.zig b/std/c/darwin.zig | |
| index 7ce29b50..1de48ec3 100644 | |
| --- a/std/c/darwin.zig | |
| +++ b/std/c/darwin.zig | |
| @@ -9,22 +9,22 @@ pub const Stat = extern struct { | |
| dev: u32, | |
| mode: u16, | |
| nlink: u16, | |
| - ino: u64, | |
| + ino: u16, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub const __int8_t = i8; | |
| pub const __uint8_t = u8; | |
| pub const __int16_t = c_short; | |
| pub const __uint16_t = c_ushort; | |
| pub const __int32_t = c_int; | |
| pub const __uint32_t = c_uint; | |
| pub const __int64_t = c_longlong; | |
| pub const __uint64_t = c_ulonglong; | |
| pub const __darwin_intptr_t = c_long; | |
| pub const __darwin_natural_t = c_uint; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/std/c/index.zig b/std/c/index.zig | |
| index 62ca99d1..315ccc52 100644 | |
| --- a/std/c/index.zig | |
| +++ b/std/c/index.zig | |
| @@ -13,7 +13,7 @@ pub extern "c" fn abort() -> noreturn; | |
| pub extern "c" fn exit(code: c_int) -> noreturn; | |
| pub extern "c" fn isatty(fd: c_int) -> c_int; | |
| pub extern "c" fn close(fd: c_int) -> c_int; | |
| -pub extern "c" fn fstat(fd: c_int, buf: &stat) -> c_int; | |
| +pub extern "c" fn fstat(fd: c_int, buf: &Stat) -> c_int; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const std = @import("std"); | |
| const warn = @import("std").debug.warn; | |
| pub fn main() -> %void { | |
| var inc_allocator = %%std.heap.IncrementingAllocator.init(10 * 1024 * 1024); | |
| defer inc_allocator.deinit(); | |
| const allocator = &inc_allocator.allocator; | |
| var file = %%std.io.File.openRead("5.txt", allocator); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const encode = @import("std").base64.encode; | |
| const warn = @import("std").debug.warn; | |
| const assert = @import("std").debug.assert; | |
| fn hexDigit(c: u8) -> u8 { | |
| switch (c) { | |
| '0'...'9' => c - '0', | |
| 'a'...'f' => c - 'a' + 10, | |
| 'A'...'F' => c - 'A' + 10, | |
| else => u8(@maxValue(u8)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/std/net.zig b/std/net.zig | |
| index 3551499c..da102eb0 100644 | |
| --- a/std/net.zig | |
| +++ b/std/net.zig | |
| @@ -162,16 +162,14 @@ pub fn parseIpLiteral(buf: []const u8) -> %Address { | |
| return error.InvalidIpLiteral; | |
| } | |
| +// TODO: cast is currently necessary on at least one prong to infer | |
| +// expression type. See https://github.com/zig-lang/zig/issues/137 |