From 2d93893081d87b4f2dd4c0b42be190fc85ae619c Mon Sep 17 00:00:00 2001 From: Khamraj Rohit Date: Mon, 26 Aug 2024 17:26:44 -0400 Subject: [PATCH] nullability fixes --- MaybeError/Maybe.cs | 6 +++--- MaybeError/MaybeExtensions.cs | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/MaybeError/Maybe.cs b/MaybeError/Maybe.cs index 4e3e4c6..f617ecf 100644 --- a/MaybeError/Maybe.cs +++ b/MaybeError/Maybe.cs @@ -4,7 +4,7 @@ using System.Diagnostics.CodeAnalysis; namespace MaybeError; -public interface IMaybe where T: class where E : Error +public interface IMaybe where E : Error { [MemberNotNullWhen(true, nameof(Error))] bool HasError { get; } @@ -46,7 +46,7 @@ public interface IMaybe where T: class where E : Error } } -public readonly struct Maybe : IMaybe where T : class where E: Error +public readonly struct Maybe : IMaybe where E: Error { [MemberNotNullWhen(true, nameof(Error))] public readonly bool HasError { get; } @@ -101,7 +101,7 @@ public readonly struct Maybe : IMaybe where T : class where E: Error } -public readonly struct Maybe : IMaybe where T : class +public readonly struct Maybe : IMaybe { [MemberNotNullWhen(true, nameof(Error))] public readonly bool HasError { get; } diff --git a/MaybeError/MaybeExtensions.cs b/MaybeError/MaybeExtensions.cs index 7c48e38..2cc8b73 100644 --- a/MaybeError/MaybeExtensions.cs +++ b/MaybeError/MaybeExtensions.cs @@ -38,33 +38,33 @@ public static class MaybeExtensions } - public static T ValueOrDefault(this IMaybe maybe, T defaultValue) where T : class where E : Error + public static T ValueOrDefault(this IMaybe maybe, T defaultValue) where E : Error { if (maybe.HasError) return defaultValue; return maybe.Value; } - public static T? ValueOrDefault(this IMaybe maybe) where T : class where E : Error + public static T? ValueOrDefault(this IMaybe maybe) where E : Error { if (maybe.HasError) return default; return maybe.Value; } - public static R As(this IMaybe maybe, Func predicate) where T : class where E : Error + public static R As(this IMaybe maybe, Func predicate) where E : Error { return predicate(maybe.Value); } - public static R? AsOrDefault(this IMaybe maybe, Func predicate) where T : class where E : Error + public static R? AsOrDefault(this IMaybe maybe, Func predicate) where E : Error { if (maybe.HasError) return default; return predicate(maybe.Value); } - public static R AsOrDefault(this IMaybe maybe, Func predicate, R defaultValue) where T : class where E : Error + public static R AsOrDefault(this IMaybe maybe, Func predicate, R defaultValue) where E : Error { if (maybe.HasError) return defaultValue;