Skip to content

Commit

Permalink
v0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
0xba1 committed Jun 30, 2022
1 parent 992d4b4 commit 123082e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
42 changes: 25 additions & 17 deletions lib/src/_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,31 @@ part 'result/querying_values.dart';
part 'result/transformers.dart';

/// `Result` is a type that that represents either success (`ok`) or failure (`err`)
/// ## Examples
///
/// Basic usage:
///
/// ```dart
/// class FallibleOpSuccess {}
/// class FallibleOpFailure {}
///
/// Result<FallibleOpSuccess, FallibleOpFailure> fallibleOp() {
/// if (true) {
/// return ok(FallibleOpSuccess());
/// } else {
/// return err(FallibleOpFailure());
/// }
/// }
///
/// final result = fallibleOp();
///
/// result.inspect((value) {
/// print('Success with value: $value');
/// }).inspectErr((error) {
/// print('Failure with error: $error');
/// });
/// }
/// ```
@immutable
class Result<T, E> {
/// Success `Result`
Expand All @@ -34,23 +59,6 @@ class Result<T, E> {
T get _ok => _okValue as T;
E get _err => _errValue as E;

/// Type of result; `ok` (success) or `err` (failure)
///
/// ## Examples
///
/// Basic usage:
///
/// ```dart
/// switch (_type) {
/// case ResultType.ok:
/// print('Success');
/// break;
/// case ResultType.err:
/// print('Failure');
/// break;
/// }
/// ```
@override
bool operator ==(Object? other) =>
other is Result &&
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: okay
description: Typesafe error-handling for dart . An implementation of rust's `Result` type in dart.
version: 0.3.0
version: 0.4.0
homepage: https://hextools.0xba1.xyz
repository: https://github.com/0xba1/okay.git

Expand Down

0 comments on commit 123082e

Please sign in to comment.