removed: `Result.return_ok` and `Result.return_err`
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 12 Jun 2023 11:51:57 +0000 (06:51 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 12 Jun 2023 11:51:57 +0000 (06:51 -0500)
CHANGELOG
core/container/result.onyx

index 4270ee1d79dceab31c2f06ddbdb661ea2e69be50..c4a37c46fdec25328a4de99131a2b888e6fca9e6 100644 (file)
--- 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:
 
index edd5958957120a4e7aa32358fc6c941d8615e08e..edf2ec52f9669a9db792c396be4ac4825e531978 100644 (file)
@@ -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 {