Skip to content

Commit

Permalink
Merge pull request #25 from feelsantiago/pattern-support
Browse files Browse the repository at this point in the history
Add new dart pattern match support
  • Loading branch information
nlfiedler authored Jun 1, 2023
2 parents 389aafc + e602942 commit 8c10121
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/src/option.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ part 'option/option_unwrap_mixin.dart';
///
/// [Option<T>] is the type used for returning an optional value. It is an
/// object with a [Some] value, and [None], representing no value.
abstract class Option<T extends Object> extends OptionBase<T>
sealed class Option<T extends Object> extends OptionBase<T>
with
OptionUnwrapMixin<T>,
OptionMatchMixin<T>,
Expand Down Expand Up @@ -54,6 +54,9 @@ class Some<T extends Object> extends Option<T> {

final T _some;

/// Wrapped value.
T get some => _some;

@override
List<Object?> get props => [_some];

Expand Down
8 changes: 7 additions & 1 deletion lib/src/result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:oxidized/src/unit.dart';
/// `Result<T, E>` is the type used for returning and propagating errors. It is
/// an object with an `Ok` value, representing success and containing a value,
/// and `Err`, representing error and containing an error value.
abstract class Result<T extends Object, E extends Object> extends Equatable {
sealed class Result<T extends Object, E extends Object> extends Equatable {
const Result._();

/// Create an `Ok` result with the given value.
Expand Down Expand Up @@ -225,6 +225,9 @@ class Ok<T extends Object, E extends Object> extends Result<T, E> {

final T _ok;

/// Wrapped value.
T get value => _ok;

@override
List<Object?> get props => [_ok];

Expand Down Expand Up @@ -373,6 +376,9 @@ class Err<T extends Object, E extends Object> extends Result<T, E> {

final E _err;

/// Wrapped error.
E get error => _err;

@override
List<Object?> get props => [_err];

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository: https://github.com/nlfiedler/oxidized.git
issue_tracker: https://github.com/nlfiedler/oxidized/issues

environment:
sdk: ">=2.15.0 <3.0.0"
sdk: ">=3.0.0"

dependencies:
equatable: ^2.0.3
Expand Down

0 comments on commit 8c10121

Please sign in to comment.