Skip to content

Commit 4b0be20

Browse files
committed
dynamic.prefer returns bool
1 parent 1488c87 commit 4b0be20

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/dynamic.zig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,16 @@ pub fn Xev(comptime bes: []const AllBackend) type {
106106

107107
/// Manually set the backend to use, but if the backend is not
108108
/// available, this will not change the backend in use.
109-
pub fn prefer(be: AllBackend) void {
109+
pub fn prefer(be: AllBackend) bool {
110110
inline for (bes) |candidate| {
111111
if (candidate == be) {
112112
const api = candidate.Api();
113113
if (api.available()) backend = subset(candidate);
114-
return;
114+
return true;
115115
}
116116
}
117+
118+
return false;
117119
}
118120

119121
pub const Loop = struct {
@@ -214,7 +216,7 @@ pub fn Xev(comptime bes: []const AllBackend) type {
214216

215217
test "prefer" {
216218
const testing = std.testing;
217-
prefer(bes[0]);
219+
try testing.expect(prefer(bes[0]));
218220
inline for (bes) |be| {
219221
if (@intFromEnum(be) == @intFromEnum(backend)) {
220222
try testing.expect(be.Api().available());

0 commit comments

Comments
 (0)