aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Thread.zig
diff options
context:
space:
mode:
authorAli Chraghi <chraghiali1@gmail.com>2022-05-22 19:36:59 +0430
committerAndrew Kelley <andrew@ziglang.org>2022-05-27 16:43:33 -0400
commit0e6285c8fc31ff866df96847fe34e660da38b4a9 (patch)
tree5d5830d5b3ce6c13041aacb7e073763551cb4852 /lib/std/Thread.zig
parentddd5b57045d38b7d1f7d5a4120302797433233cd (diff)
downloadzig-0e6285c8fc31ff866df96847fe34e660da38b4a9.tar.gz
zig-0e6285c8fc31ff866df96847fe34e660da38b4a9.zip
math: make `cast` return optional instead of an error
Diffstat (limited to 'lib/std/Thread.zig')
-rw-r--r--lib/std/Thread.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig
index 06903a9e91..aaf0fc3440 100644
--- a/lib/std/Thread.zig
+++ b/lib/std/Thread.zig
@@ -88,7 +88,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
.windows => {
var buf: [max_name_len]u16 = undefined;
const len = try std.unicode.utf8ToUtf16Le(&buf, name);
- const byte_len = math.cast(c_ushort, len * 2) catch return error.NameTooLong;
+ const byte_len = math.cast(c_ushort, len * 2) orelse return error.NameTooLong;
// Note: NT allocates its own copy, no use-after-free here.
const unicode_string = os.windows.UNICODE_STRING{
@@ -526,7 +526,7 @@ const WindowsThreadImpl = struct {
// Windows appears to only support SYSTEM_INFO.dwAllocationGranularity minimum stack size.
// Going lower makes it default to that specified in the executable (~1mb).
// Its also fine if the limit here is incorrect as stack size is only a hint.
- var stack_size = std.math.cast(u32, config.stack_size) catch std.math.maxInt(u32);
+ var stack_size = std.math.cast(u32, config.stack_size) orelse std.math.maxInt(u32);
stack_size = std.math.max(64 * 1024, stack_size);
instance.thread.thread_handle = windows.kernel32.CreateThread(