diff options
| author | Ali Chraghi <chraghiali1@gmail.com> | 2022-05-22 19:36:59 +0430 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-05-27 16:43:33 -0400 |
| commit | 0e6285c8fc31ff866df96847fe34e660da38b4a9 (patch) | |
| tree | 5d5830d5b3ce6c13041aacb7e073763551cb4852 /src/Module.zig | |
| parent | ddd5b57045d38b7d1f7d5a4120302797433233cd (diff) | |
| download | zig-0e6285c8fc31ff866df96847fe34e660da38b4a9.tar.gz zig-0e6285c8fc31ff866df96847fe34e660da38b4a9.zip | |
math: make `cast` return optional instead of an error
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/Module.zig b/src/Module.zig index bc84d84ae8..7c19c4dab6 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -4395,7 +4395,7 @@ pub fn embedFile(mod: *Module, cur_file: *File, rel_file_path: []const u8) !*Emb .inode = actual_stat.inode, .mtime = actual_stat.mtime, }; - const size_usize = try std.math.cast(usize, actual_stat.size); + const size_usize = std.math.cast(usize, actual_stat.size) orelse return error.Overflow; const bytes = try file.readToEndAllocOptions(gpa, std.math.maxInt(u32), size_usize, 1, 0); errdefer gpa.free(bytes); @@ -4435,7 +4435,7 @@ pub fn detectEmbedFileUpdate(mod: *Module, embed_file: *EmbedFile) !void { if (unchanged_metadata) return; const gpa = mod.gpa; - const size_usize = try std.math.cast(usize, stat.size); + const size_usize = std.math.cast(usize, stat.size) orelse return error.Overflow; const bytes = try file.readToEndAllocOptions(gpa, std.math.maxInt(u32), size_usize, 1, 0); gpa.free(embed_file.bytes); embed_file.bytes = bytes; |
