From: Brendan Hansen Date: Sun, 3 Sep 2023 16:23:38 +0000 (-0500) Subject: bufixes; made `any_to_map` return an optional X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=97240c5182472685b0544cc00663a7dfae863e3d;p=onyx.git bufixes; made `any_to_map` return an optional --- diff --git a/core/container/result.onyx b/core/container/result.onyx index edf2ec52..7183b8f6 100644 --- a/core/container/result.onyx +++ b/core/container/result.onyx @@ -26,7 +26,7 @@ Result :: union (Ok_Type: type_expr, Err_Type: type_expr) { #inject Result { #doc "Returns true if the result contains an Ok value." - is_ok :: (r: #Self) { + is_ok :: (r: #Self) -> bool { switch r { case .Ok do return true; case #default do return false; @@ -34,7 +34,7 @@ Result :: union (Ok_Type: type_expr, Err_Type: type_expr) { } #doc "Returns true if the result contains an Err value." - is_err :: (r: #Self) { + is_err :: (r: #Self) -> bool { switch r { case .Err do return true; case #default do return false; diff --git a/core/misc/any_utils.onyx b/core/misc/any_utils.onyx index b0564b3c..6a8d208a 100644 --- a/core/misc/any_utils.onyx +++ b/core/misc/any_utils.onyx @@ -118,15 +118,15 @@ any_member :: #match #locked { `m` would have two keys, "x" and "y". """ -any_to_map :: (v: any) -> (Map(str, any), success: bool) { +any_to_map :: (v: any) -> ? Map(str, any) { vals := v; - if get_type_info(vals.type).kind == .Pointer { + if vals.type->info().kind == .Pointer { vals = any_dereference(vals); } - val_info := cast(&Type_Info_Struct) get_type_info(vals.type); + val_info := vals.type->info()->as_struct(); if val_info.kind != .Struct { - return .{}, false; + return .{}; } out: Map(str, any); @@ -134,7 +134,7 @@ any_to_map :: (v: any) -> (Map(str, any), success: bool) { out->put(it.name, any_selector(vals, it.name)); } - return out, true; + return out; } #doc "Creates an iterator out of an array-like any."