diff --git a/lib/src/_result.dart b/lib/src/_result.dart index 39a4084..a334b81 100644 --- a/lib/src/_result.dart +++ b/lib/src/_result.dart @@ -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 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 { /// Success `Result` @@ -34,23 +59,6 @@ class Result { 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 && diff --git a/pubspec.yaml b/pubspec.yaml index 373d569..24229c9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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