diff --git a/lib/src/option/future_option.dart b/lib/src/option/future_option.dart index 42ae10f..ceb4a78 100644 --- a/lib/src/option/future_option.dart +++ b/lib/src/option/future_option.dart @@ -115,7 +115,7 @@ extension FutureOptionExtension on FutureOption { //************************************************************************// - // ignore: library_private_types_in_public_api + // ignore: library_private_types_in_public_api Future operator [](_OptionEarlyReturnKey op) { return then((value) => value[op]); } diff --git a/lib/src/option/option.dart b/lib/src/option/option.dart index bb18aa7..a719d0c 100644 --- a/lib/src/option/option.dart +++ b/lib/src/option/option.dart @@ -11,7 +11,7 @@ sealed class Option { /// immediately the context that "$" belongs to is returned with None(). e.g. /// ``` /// Option intNone() => const None(); - /// + /// /// Option earlyReturn(int val) => Option(($){ /// int x = intNone()[$]; // returns [None] immediately /// return Some(val + 3); @@ -42,8 +42,9 @@ sealed class Option { ///``` /// This should be used at the top level of a function as above. Passing "$" to any other functions, nesting, or /// attempting to bring "$" out of the original scope should be avoided. - // ignore: library_private_types_in_public_api - static Future> async(_OptionAsyncEarlyReturnFunction fn) async { + static Future> async( + // ignore: library_private_types_in_public_api + _OptionAsyncEarlyReturnFunction fn) async { try { return await fn(const _OptionEarlyReturnKey._()); } on _OptionEarlyReturnNotification catch (_) { @@ -479,8 +480,8 @@ final class _OptionEarlyReturnNotification { typedef _OptionEarlyReturnFunction = Option Function( _OptionEarlyReturnKey); -typedef _OptionAsyncEarlyReturnFunction = Future> Function( - _OptionEarlyReturnKey); +typedef _OptionAsyncEarlyReturnFunction = Future> + Function(_OptionEarlyReturnKey); //************************************************************************// diff --git a/lib/src/result/result.dart b/lib/src/result/result.dart index 8d71b42..6cef58e 100644 --- a/lib/src/result/result.dart +++ b/lib/src/result/result.dart @@ -14,17 +14,16 @@ part 'future_result.dart'; /// .org/std/result/enum.Result.html /// {@endtemplate} sealed class Result { - /// Creates a context for early return, similar to "Do notation". /// Here "$" is used as the "Early Return Key". when "$" is used on a type [Err], - /// immediately the context that "$" belongs to is returned with that [Err]. + /// immediately the context that "$" belongs to is returned with that [Err]. /// Works like the Rust "?" operator, which is a "Early Return Operator". /// e.g. /// ```dart /// Result innerFn() => Err("message"); - /// + /// /// Result innerFn2() => Ok(1); - /// + /// /// Result earlyReturn() => Result(($) { /// int y = 2; /// int x = innerFn()[$]; // returns [Err] here immediately @@ -46,7 +45,7 @@ sealed class Result { /// Creates a async context for early return, similar to "Do notation". /// Here "$" is used as the "Early Return Key". when "$" is used on a type [Err], - /// immediately the context that "$" belongs to is returned with that [Err]. + /// immediately the context that "$" belongs to is returned with that [Err]. /// Works like the Rust "?" operator, which is a "Early Return Operator". /// e.g. /// diff --git a/test/option/option_future_test.dart b/test/option/option_future_test.dart index 2d8d571..5377af8 100644 --- a/test/option/option_future_test.dart +++ b/test/option/option_future_test.dart @@ -32,7 +32,8 @@ void main() { expect(await x.expect("Error"), 1); x = Future.value(const None()); - expect(() async => await x.expect("Error occurred"), throwsA(isA())); + expect( + () async => await x.expect("Error occurred"), throwsA(isA())); }); test("filter", () async { @@ -238,7 +239,7 @@ void main() { double x = await doubleNone()[$]; return Some((val + x).toInt()); }); - final _ = await earlyReturn(2); + final _ = await earlyReturn(2); expect(await earlyReturn(2), const None()); }); diff --git a/test/result/future_result_test.dart b/test/result/future_result_test.dart index cf6b19b..9ccd7f8 100644 --- a/test/result/future_result_test.dart +++ b/test/result/future_result_test.dart @@ -214,8 +214,7 @@ void main() { }); test('With Exit', () async { - FutureResult testDoNotation() => - Result.async(($) async { + FutureResult testDoNotation() => Result.async(($) async { int y = Ok(1)[$]; int z = Ok(1).mapErr((err) => err.toString())[$]; int x = await regularErr()[$]; @@ -225,8 +224,7 @@ void main() { }); test('With Exit 2', () async { - FutureResult testDoNotation() => - Result.async(($) async { + FutureResult testDoNotation() => Result.async(($) async { int y = Ok(1)[$]; int z = Ok(1).mapErr((err) => err.toString())[$]; int x = await earlyReturnErr()[$]; @@ -240,8 +238,7 @@ void main() { }); test('Normal Ok', () async { - FutureResult testDoNotation() => - Result.async(($) async { + FutureResult testDoNotation() => Result.async(($) async { int y = 3; int z = 2; int x = 1; @@ -251,8 +248,7 @@ void main() { }); test('Normal Err', () async { - FutureResult testDoNotation() => - Result.async(($) async { + FutureResult testDoNotation() => Result.async(($) async { int y = 3; int z = 2; int x = 1;