Make error sets explicit
This commit is contained in:
@ -227,14 +227,15 @@ pub fn Window(comptime TUserData: type) type {
|
||||
reserved: u27 = 0,
|
||||
};
|
||||
|
||||
pub fn open(title: [*:0]const u8, width: u32, height: u32, flags: OpenFlags) !Window(TUserData) {
|
||||
const OpenError = error{OpenFailed};
|
||||
pub fn open(title: [*:0]const u8, width: u32, height: u32, flags: OpenFlags) OpenError!Window(TUserData) {
|
||||
const cwin: ?*c.mfb_window = c.mfb_open_ex(title, width, height, @bitCast(u32, flags));
|
||||
if (cwin) |value| {
|
||||
const win = Window(TUserData){ .cwin = value };
|
||||
assert(@bitCast(usize, win) == @ptrToInt(win.cwin));
|
||||
return win;
|
||||
} else {
|
||||
return error.ItBroke;
|
||||
return OpenError.OpenFailed;
|
||||
}
|
||||
}
|
||||
|
||||
@ -367,12 +368,12 @@ test "set and get target FPS" {
|
||||
pub const Timer = extern struct {
|
||||
ctimer: *c.mfb_timer,
|
||||
|
||||
pub fn init() !Timer {
|
||||
pub fn init() std.mem.Allocator.Error!Timer {
|
||||
const ctimer: ?*c.mfb_timer = c.mfb_timer_create();
|
||||
if (ctimer) |value| {
|
||||
return Timer{ .ctimer = value };
|
||||
} else {
|
||||
return error.ItBroke;
|
||||
return std.mem.Allocator.Error.OutOfMemory;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user