using System.Diagnostics.CodeAnalysis; namespace InnovEnergy.Lib.Utils; public static class NullableUtilsStruct { public static IEnumerable ToEnumerable(this T? t) where T : struct { if (t.HasValue) yield return t.Value; } public static T ThrowIfNull(this T? t) where T : struct => ThrowIfNull(t, null); public static T ThrowIfNull(this T? t, String? message) where T : struct { if (!t.HasValue) throw new NullReferenceException(message); return t.Value; } public static Boolean IsNull([NotNullWhen(returnValue: false)] this T? t) where T : struct => t.HasValue; }