Skip to content

Commit

Permalink
Updated documentation for release 1.0.0-rc.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
Salvatore Isaja committed Oct 8, 2022
1 parent e33b088 commit 60d5c06
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 81 deletions.
2 changes: 1 addition & 1 deletion DiscriminatedOnions/DiscriminatedOnions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>1.0.0-rc</Version>
<Version>1.0.0-rc.1</Version>
<Authors>Salvo Isaja</Authors>
<Company>Salvo Isaja</Company>
<Copyright>Copyright 2022 Salvatore Isaja</Copyright>
Expand Down
8 changes: 4 additions & 4 deletions DiscriminatedOnions/Option.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ namespace DiscriminatedOnions;

public readonly record struct Option<T>
{
public bool IsSome { get; private init; }
public T Value { get; private init; }

public static readonly Option<T> None = new(false, default!);
public bool IsSome { get; }
public T Value { get; }

public U Match<U>(Func<U> onNone, Func<T, U> onSome) =>
IsSome ? onSome(Value) : onNone();
Expand All @@ -44,6 +42,8 @@ public void Match(Action onNone, Action<T> onSome)
if (IsSome) onSome(Value); else onNone();
}

internal static readonly Option<T> None = new(false, default!);

internal Option(bool isSome, T value)
{
IsSome = isSome;
Expand Down
10 changes: 5 additions & 5 deletions DiscriminatedOnions/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ namespace DiscriminatedOnions;

public readonly record struct Result<T, TError>
{
public bool IsOk { get; private init; }
public T ResultValue { get; private init; }
public TError ErrorValue { get; private init; }
public bool IsOk { get; }
public T ResultValue { get; }
public TError ErrorValue { get; }

public U Match<U>(Func<TError, U> onError, Func<T, U> onOk) =>
this switch
Expand All @@ -50,10 +50,10 @@ public void Match(Action<TError> onError, Action<T> onOk)
}
}

internal Result(bool isOk, T value, TError errorValue)
internal Result(bool isOk, T resultValue, TError errorValue)
{
IsOk = isOk;
ResultValue = value;
ResultValue = resultValue;
ErrorValue = errorValue;
}
}
Expand Down
Loading

0 comments on commit 60d5c06

Please sign in to comment.