From 0bf70c0e2816437b093e1ed5c1015ce9850b14c9 Mon Sep 17 00:00:00 2001 From: utamori Date: Sun, 27 Oct 2024 15:51:22 +0900 Subject: [PATCH] migrate the Result class to sealed class --- pkgs/async/CHANGELOG.md | 4 ++++ pkgs/async/lib/async.dart | 2 -- pkgs/async/lib/src/result/error.dart | 5 +---- pkgs/async/lib/src/result/result.dart | 7 ++++--- pkgs/async/lib/src/result/value.dart | 5 +---- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/pkgs/async/CHANGELOG.md b/pkgs/async/CHANGELOG.md index 06ac7d11..39efc9cd 100644 --- a/pkgs/async/CHANGELOG.md +++ b/pkgs/async/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.13.0-wip + +- migrate the Result class to sealed class + ## 2.12.0 - Require Dart 3.4. diff --git a/pkgs/async/lib/async.dart b/pkgs/async/lib/async.dart index 67480e62..1b489aa2 100644 --- a/pkgs/async/lib/async.dart +++ b/pkgs/async/lib/async.dart @@ -24,10 +24,8 @@ export 'src/future_group.dart'; export 'src/lazy_stream.dart'; export 'src/null_stream_sink.dart'; export 'src/restartable_timer.dart'; -export 'src/result/error.dart'; export 'src/result/future.dart'; export 'src/result/result.dart'; -export 'src/result/value.dart'; export 'src/single_subscription_transformer.dart'; export 'src/sink_base.dart'; export 'src/stream_closer.dart'; diff --git a/pkgs/async/lib/src/result/error.dart b/pkgs/async/lib/src/result/error.dart index 48f71b1d..b286786e 100644 --- a/pkgs/async/lib/src/result/error.dart +++ b/pkgs/async/lib/src/result/error.dart @@ -2,10 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'dart:async'; - -import 'result.dart'; -import 'value.dart'; +part of 'result.dart'; /// A result representing a thrown error. class ErrorResult implements Result { diff --git a/pkgs/async/lib/src/result/result.dart b/pkgs/async/lib/src/result/result.dart index 124ccefa..c6ad350d 100644 --- a/pkgs/async/lib/src/result/result.dart +++ b/pkgs/async/lib/src/result/result.dart @@ -7,10 +7,11 @@ import 'dart:async'; import '../stream_sink_transformer.dart'; import 'capture_sink.dart'; import 'capture_transformer.dart'; -import 'error.dart'; import 'release_sink.dart'; import 'release_transformer.dart'; -import 'value.dart'; + +part 'value.dart'; +part 'error.dart'; /// The result of a computation. /// @@ -22,7 +23,7 @@ import 'value.dart'; /// /// A [Future] represents a potential result, one that might not have been /// computed yet, and a [Result] is always a completed and available result. -abstract class Result { +sealed class Result { /// A stream transformer that captures a stream of events into [Result]s. /// /// The result of the transformation is a stream of [Result] values and no diff --git a/pkgs/async/lib/src/result/value.dart b/pkgs/async/lib/src/result/value.dart index 3872dd0b..9c310e4a 100644 --- a/pkgs/async/lib/src/result/value.dart +++ b/pkgs/async/lib/src/result/value.dart @@ -2,10 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'dart:async'; - -import 'error.dart'; -import 'result.dart'; +part of 'result.dart'; /// A result representing a returned value. class ValueResult implements Result {