okerr

Last updated:

0 purchases

okerr Image
okerr Images
Add to Cart

Description:

okerr

okerr #


Okerr is a Dart package for Result type of Rust.
Methods #
The majority of methods in std::result of Rust has been implemented. The criteria for implementation are:

The method is not in the nightly-only experimental API. For example, is_ok_and is not implemented in this package.
The methods that deal with ownership and borrowing do not make sense in the context of Dart. Thus, as_mut, as_deref, as_deref_mut, etc. are not implemented.
The methods that deal with iteration are not implemented such as iter and iter_mut.
Unsafe methods are not implemented.

An extra match method is implemented to mimic the pattern matching with Results in Rust.
Check the API documentation in order to see all the implemented methods.
Extra Method: match #
match is a method that mimics the pattern matching with Results in Rust. See the example:
final result1 = Ok(0);
final value1 = result1.match(
ok: (value) => value == 0,
err: (error) => false,
); // value1 is `true`

final result2 = Err(0);
final value2 = result2.match(
ok: (value) => value == 0,
err: (error) => false,
); // value2 is `false`
copied to clipboard
Mentions #
result package is another one targeting the same thing, but it's not been updated for years now whereas Dart has changed a lot. It can be error-prone to use.
dartz is another alternative. It is essentially a functional programming library and comes with many things such as immutable persistent collections, type class instances etc. Its Either class holds similarity to Result.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.