Skip to content

Commit

Permalink
feat: no need to call unwrapUnchecked or unwrapErrUnchecked inside Re…
Browse files Browse the repository at this point in the history
…sult
  • Loading branch information
yifanwww committed Jun 2, 2024
1 parent 842e55b commit c318048
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Result.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,28 @@ export class RustlikeResult<T, E> implements Result<T, E> {

inspect(fn: (value: T) => void): this {
if (this.isOk()) {
fn(this.unwrapUnchecked());
fn(this._value!);
}
return this;
}

async inspectAsync(fn: (value: T) => void | Promise<void>): Promise<this> {
if (this.isOk()) {
await fn(this.unwrapUnchecked());
await fn(this._value!);
}
return this;
}

inspectErr(fn: (err: E) => void): this {
if (this.isErr()) {
fn(this.unwrapErrUnchecked());
fn(this._error!);
}
return this;
}

async inspectErrAsync(fn: (err: E) => void | Promise<void>): Promise<this> {
if (this.isErr()) {
await fn(this.unwrapErrUnchecked());
await fn(this._error!);
}
return this;
}
Expand Down

0 comments on commit c318048

Please sign in to comment.