const user = getUser() orelse return error.NoUser;
If you only need user for a narrow scope like you would get from match, you can also use if to unwrap the optional. if (getUser()) |user| {
// use user
} else {
return error.NoUser;
}