fix attribute on HasValue
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PackageId>MaybeError</PackageId>
|
<PackageId>MaybeError</PackageId>
|
||||||
<Version>1.0.3</Version>
|
<Version>1.0.4</Version>
|
||||||
<Authors>Amatsugu</Authors>
|
<Authors>Amatsugu</Authors>
|
||||||
<PackageDescription>Errors as values</PackageDescription>
|
<PackageDescription>Errors as values</PackageDescription>
|
||||||
<RepositoryUrl>https://github.com/Amatsugu/MaybeError</RepositoryUrl>
|
<RepositoryUrl>https://github.com/Amatsugu/MaybeError</RepositoryUrl>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public interface IValueMaybe<T, E> where T : struct where E : Error
|
|||||||
{
|
{
|
||||||
[MemberNotNullWhen(true, nameof(Error))]
|
[MemberNotNullWhen(true, nameof(Error))]
|
||||||
bool HasError { get; }
|
bool HasError { get; }
|
||||||
|
[MemberNotNullWhen(false, nameof(Error))]
|
||||||
bool HasValue => !HasError;
|
bool HasValue => !HasError;
|
||||||
E? Error { get; }
|
E? Error { get; }
|
||||||
T Value { get; }
|
T Value { get; }
|
||||||
@@ -18,6 +19,7 @@ public readonly struct ValueMaybe<T, E> : IValueMaybe<T, E> where T : struct whe
|
|||||||
{
|
{
|
||||||
[MemberNotNullWhen(true, nameof(Error))]
|
[MemberNotNullWhen(true, nameof(Error))]
|
||||||
public readonly bool HasError { get; }
|
public readonly bool HasError { get; }
|
||||||
|
[MemberNotNullWhen(false, nameof(Error))]
|
||||||
public readonly bool HasValue => !HasError;
|
public readonly bool HasValue => !HasError;
|
||||||
public readonly E? Error { get; }
|
public readonly E? Error { get; }
|
||||||
public readonly T Value => HasError ? throw Error.GetException() : _value;
|
public readonly T Value => HasError ? throw Error.GetException() : _value;
|
||||||
|
|||||||
Reference in New Issue
Block a user