Skip to content

Commit

Permalink
Update some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
thinker227 committed Jan 1, 2024
1 parent b6667e4 commit 104f3ce
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/Rascal/Result_Matching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public bool TryGetError(out Error error, out T value)
}

/// <summary>
/// Gets the ok value of the result, or <see langword="default"/> if the result is not ok.
/// Gets the ok value of the result, or <see langword="default"/> if the result is an error.
/// </summary>
[Pure]
public T? GetValueOrDefault() =>
Expand All @@ -150,20 +150,19 @@ public bool TryGetError(out Error error, out T value)
: default;

/// <summary>
/// Gets the ok value of the result, or a default value if the result is not ok.
/// Gets the ok value of the result, or a default value if the result is an error.
/// </summary>
/// <param name="default">The default value to return if the result is not ok.</param>
/// <param name="default">The default value to return if the result is an error.</param>
[Pure]
public T GetValueOr(T @default) =>
IsOk
? value!
: @default;

/// <summary>
/// Gets the ok value of the result, or a default value if the result is not ok.
/// Gets the ok value of the result, or a default value if the result is an error.
/// </summary>
/// <param name="getDefault">A function to get a default value to return
/// if the result is not ok.</param>
/// <param name="getDefault">A function to get a default value to return if the result is an error.</param>
[Pure]
public T GetValueOr(Func<T> getDefault) =>
IsOk
Expand All @@ -183,7 +182,7 @@ public T GetValueOr(Func<Error, T> getValue) =>

/// <summary>
/// Unwraps the ok value of the result.
/// Throws an <see cref="UnwrapException"/> if the result is not ok.
/// Throws an <see cref="UnwrapException"/> if the result is an error.
/// </summary>
/// <remarks>
/// This API is <b>unsafe</b> in the sense that it might intentionally throw an exception.
Expand All @@ -205,17 +204,17 @@ public static explicit operator T(Result<T> result) =>

/// <summary>
/// Expects the result to be ok, throwing an <see cref="UnwrapException"/>
/// with a specified message if the result is not ok.
/// with a specified message if the result is an error.
/// </summary>
/// <param name="error">The message to construct the <see cref="UnwrapException"/>
/// to throw using if the result is not ok.</param>
/// to throw using if the result is an error.</param>
/// <remarks>
/// This API is <b>unsafe</b> in the sense that it might intentionally throw an exception.
/// Please only use this API if the caller knows without a reasonable shadow of a doubt
/// that this operation is safe, or that an exception is acceptable to be thrown.
/// </remarks>
/// <returns>The ok value of the result.</returns>
/// <exception cref="UnwrapException">The result is not ok.</exception>
/// <exception cref="UnwrapException">The result is an error.</exception>
[Pure]
public T Expect(string error) =>
IsOk
Expand Down

0 comments on commit 104f3ce

Please sign in to comment.