aboutsummaryrefslogtreecommitdiff
path: root/src/bun.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-09-19 23:03:11 -0700
committerGravatar GitHub <noreply@github.com> 2023-09-19 23:03:11 -0700
commitedee1e3d04c80f5301b4eeb8eef2a92a0ed5823c (patch)
treed4af23bce9e3e80957a4739ed596baab27fdea32 /src/bun.zig
parente2fb524993137bce0a6d3a2a45783877efff4f82 (diff)
downloadbun-edee1e3d04c80f5301b4eeb8eef2a92a0ed5823c.tar.gz
bun-edee1e3d04c80f5301b4eeb8eef2a92a0ed5823c.tar.zst
bun-edee1e3d04c80f5301b4eeb8eef2a92a0ed5823c.zip
Show when a newer version is available in the install screen (#5780)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.zig')
-rw-r--r--src/bun.zig23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/bun.zig b/src/bun.zig
index 790ec5d04..c7b15340e 100644
--- a/src/bun.zig
+++ b/src/bun.zig
@@ -1841,3 +1841,26 @@ pub fn fdi32(fd_: anytype) i32 {
}
pub const OSPathSlice = if (Environment.isWindows) [:0]const u16 else [:0]const u8;
+pub const LazyBoolValue = enum {
+ unknown,
+ no,
+ yes,
+};
+/// Create a lazily computed boolean value.
+/// Getter must be a function that takes a pointer to the parent struct and returns a boolean.
+/// Parent must be a type which contains the field we are getting.
+pub fn LazyBool(comptime Getter: anytype, comptime Parent: type, comptime field: string) type {
+ return struct {
+ value: LazyBoolValue = .unknown,
+ pub fn get(self: *@This()) bool {
+ if (self.value == .unknown) {
+ self.value = switch (Getter(@fieldParentPtr(Parent, field, self))) {
+ true => .yes,
+ false => .no,
+ };
+ }
+
+ return self.value == .yes;
+ }
+ };
+}