From b247a27f4d87e58edb4edfacdc1e6a70f726ed0f Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 12 Jun 2023 06:51:57 -0500 Subject: [PATCH] removed: `Result.return_ok` and `Result.return_err` --- CHANGELOG | 3 +++ core/container/result.onyx | 10 ++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4270ee1d..c4a37c46 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,8 +21,11 @@ Removals: - Remove old syntax for quoted blocks, `#quote` and `#()`. - Switch to `[] {}` and `[] ()` respectively. - Old WASI specific modules for time and environment variables. +- `Result.return_err` and `Result.return_ok`. + - Unnecessary with new union features. Changes: +- Added support for optionals in `json.encode`, `json.from_any`, and `json.as_any`. Bugfixes: diff --git a/core/container/result.onyx b/core/container/result.onyx index edd59589..edf2ec52 100644 --- a/core/container/result.onyx +++ b/core/container/result.onyx @@ -25,12 +25,6 @@ Result :: union (Ok_Type: type_expr, Err_Type: type_expr) { #inject Result { - #doc "Quick way to return an Ok from a procedure." - return_ok :: macro (x: $T) do return .{ Ok = x }; - - #doc "Quick way to return an Err from a procedure." - return_err :: macro (x: $T) do return .{ Err = x }; - #doc "Returns true if the result contains an Ok value." is_ok :: (r: #Self) { switch r { @@ -135,7 +129,7 @@ Result :: union (Ok_Type: type_expr, Err_Type: type_expr) { procedure. Otherwise, the Ok value is returned. f :: () -> Result(i32, str) { - Result.return_err("Oh no..."); + return .{ Err = "Oh no..." }; } g :: () -> Result(str, str) { @@ -143,7 +137,7 @@ Result :: union (Ok_Type: type_expr, Err_Type: type_expr) { v := f()->forward_err(); println(v); - Result.return_ok("Success!"); + return .{ Ok = "Success!" }; } """ forward_err :: macro (r: Result($T, $E)) -> T { -- 2.25.1