Skip to content

Commit

Permalink
Add Rust reference comments for on{Success,Failure}
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbull committed Mar 2, 2024
1 parent 05d50b7 commit 73a7115
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import kotlin.contracts.contract

/**
* Invokes an [action] if this [Result] is [Ok].
*
* - Rust: [Result.inspect](https://doc.rust-lang.org/std/result/enum.Result.html#method.inspect)
*/
public inline infix fun <V, E> Result<V, E>.onSuccess(action: (V) -> Unit): Result<V, E> {
contract {
Expand All @@ -20,6 +22,8 @@ public inline infix fun <V, E> Result<V, E>.onSuccess(action: (V) -> Unit): Resu

/**
* Invokes an [action] if this [Result] is [Err].
*
* - Rust [Result.inspect_err](https://doc.rust-lang.org/std/result/enum.Result.html#method.inspect_err)
*/
public inline infix fun <V, E> Result<V, E>.onFailure(action: (E) -> Unit): Result<V, E> {
contract {
Expand Down

0 comments on commit 73a7115

Please sign in to comment.