Skip to content

Commit 0449a9b

Browse files
giacomocavalierilpil
authored andcommitted
Rename result.recover to result.try_recover
1 parent 46a898e commit 0449a9b

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Unreleased
44

5-
- The `result` module gains the `recover` function.
5+
- The `result` module gains the `try_recover` function.
66

77
## v0.29.1 - 2023-06-01
88

src/gleam/result.gleam

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,21 +458,21 @@ pub fn values(results: List(Result(a, e))) -> List(a) {
458458
/// ## Examples
459459
///
460460
/// ```gleam
461-
/// > Ok(1) |> recover(with: fn(_) { Error("failed to recover") })
461+
/// > Ok(1) |> try_recover(with: fn(_) { Error("failed to recover") })
462462
/// Ok(1)
463463
/// ```
464464
///
465465
/// ```gleam
466-
/// > Error(1) |> recover(with: fn(error) { Ok(error + 1) })
466+
/// > Error(1) |> try_recover(with: fn(error) { Ok(error + 1) })
467467
/// Ok(2)
468468
/// ```
469469
///
470470
/// ```gleam
471-
/// > Error(1) |> recover(with: fn(error) { Error("failed to recover") })
471+
/// > Error(1) |> try_recover(with: fn(error) { Error("failed to recover") })
472472
/// Error("failed to recover")
473473
/// ```
474474
///
475-
pub fn recover(
475+
pub fn try_recover(
476476
result: Result(a, e),
477477
with fun: fn(e) -> Result(a, f),
478478
) -> Result(a, f) {

test/gleam/result_test.gleam

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,16 @@ pub fn values_test() {
250250
|> should.equal([1, 3])
251251
}
252252

253-
pub fn recover_test() {
253+
pub fn try_recover_test() {
254254
Ok(1)
255-
|> result.recover(fn(_) { panic })
255+
|> result.try_recover(fn(_) { panic })
256256
|> should.equal(Ok(1))
257257

258258
Error(1)
259-
|> result.recover(fn(n) { Ok(n + 1) })
259+
|> result.try_recover(fn(n) { Ok(n + 1) })
260260
|> should.equal(Ok(2))
261261

262262
Error(1)
263-
|> result.recover(fn(_) { Error("failed to recover") })
263+
|> result.try_recover(fn(_) { Error("failed to recover") })
264264
|> should.equal(Error("failed to recover"))
265265
}

0 commit comments

Comments
 (0)