diff --git a/lib/src/result/result.dart b/lib/src/result/result.dart index 081191a..ec27d0c 100644 --- a/lib/src/result/result.dart +++ b/lib/src/result/result.dart @@ -66,7 +66,7 @@ sealed class Result { /// 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. Also, using the method [catchError] on the futures after /// the `[$]` operator might lead to unexpected behaviour. - static Future> earlyAsync( + static Future> async( // ignore: library_private_types_in_public_api _AsyncResultEarlyReturnFunction fn, ) async { diff --git a/test/result/future_result_test.dart b/test/result/future_result_test.dart index a8a9af3..cf6b19b 100644 --- a/test/result/future_result_test.dart +++ b/test/result/future_result_test.dart @@ -169,10 +169,10 @@ void main() { //************************************************************************// group("Early Return", () { - FutureResult earlyReturnErr() => Result.earlyAsync(($) { + FutureResult earlyReturnErr() => Result.async(($) { return Future.value(Err("return error")); }); - FutureResult earlyReturnOk() => Result.earlyAsync(($) { + FutureResult earlyReturnOk() => Result.async(($) { return Future.value(Ok(2)); }); FutureResult regularOk() async { @@ -189,7 +189,7 @@ void main() { test('No Exit', () async { FutureResult add3(int val) { - return Result.earlyAsync(($) async { + return Result.async(($) async { int x = await regularOk()[$]; int y = Ok(1)[$]; int z = Ok(1).mapErr((err) => err.toString())[$]; @@ -202,7 +202,7 @@ void main() { test('No Exit 2', () async { FutureResult add3(int val) { - return Result.earlyAsync(($) async { + return Result.async(($) async { int x = await earlyReturnOk()[$]; int y = Ok(1)[$]; int z = Ok(1).mapErr((err) => err.toString())[$]; @@ -215,7 +215,7 @@ void main() { test('With Exit', () async { FutureResult testDoNotation() => - Result.earlyAsync(($) async { + Result.async(($) async { int y = Ok(1)[$]; int z = Ok(1).mapErr((err) => err.toString())[$]; int x = await regularErr()[$]; @@ -226,7 +226,7 @@ void main() { test('With Exit 2', () async { FutureResult testDoNotation() => - Result.earlyAsync(($) async { + Result.async(($) async { int y = Ok(1)[$]; int z = Ok(1).mapErr((err) => err.toString())[$]; int x = await earlyReturnErr()[$]; @@ -241,7 +241,7 @@ void main() { test('Normal Ok', () async { FutureResult testDoNotation() => - Result.earlyAsync(($) async { + Result.async(($) async { int y = 3; int z = 2; int x = 1; @@ -252,7 +252,7 @@ void main() { test('Normal Err', () async { FutureResult testDoNotation() => - Result.earlyAsync(($) async { + Result.async(($) async { int y = 3; int z = 2; int x = 1; @@ -262,7 +262,7 @@ void main() { }); test('Wrong type', () async { - FutureResult testDoNotation() => Result.earlyAsync(($) { + FutureResult testDoNotation() => Result.async(($) { // wrongType()[$]; // does not compile as expected wrongType(); return Future.value(Err(""));