You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dyon uses a separate dynamic type for result values. The result type has two variants, err and ok. It has a lot of common with option value, but there are a few differences.
err(x) creates an error with message x, using deep clone
ok(x) creates a successful result with value x, using deep clone
unwrap(x) unwraps a result type, when error prints error message plus ? trace messages
unwrap_err(x) unwraps error message
is_err(x) returns true if result is an error
For both result and option, the ? operator propagates the error (requires -> on function):
x?, x.a?, x[0]?.b.c? etc.
foo()? or following after any expression
When a the value is none() or err(x), the ? operator propagates the error. Returns from the function. A trace message is added to help debugging on unwrap, describing where the ? operation happened. some(x) is converted to ok(x).
This is designed for:
Explicit decide whether to use result
Check when mutating a variable that it is result
Convenient for debugging
Common way of handling errors
The text was updated successfully, but these errors were encountered:
Dyon uses a separate dynamic type for result values. The result type has two variants,
err
andok
. It has a lot of common with option value, but there are a few differences.err(x)
creates an error with messagex
, using deep cloneok(x)
creates a successful result with valuex
, using deep cloneunwrap(x)
unwraps a result type, when error prints error message plus?
trace messagesunwrap_err(x)
unwraps error messageis_err(x)
returnstrue
if result is an errorFor both result and option, the
?
operator propagates the error (requires->
on function):x?
,x.a?
,x[0]?.b.c?
etc.foo()?
or following after any expressionWhen a the value is
none()
orerr(x)
, the?
operator propagates the error. Returns from the function. A trace message is added to help debugging onunwrap
, describing where the?
operation happened.some(x)
is converted took(x)
.This is designed for:
The text was updated successfully, but these errors were encountered: