FruityFoundation/Base/Structures/MaybeExtensions.cs
Kyle Ratti e12137b302
feat: move FSharp stuff into FsBase
This drops the FSharp.Core dependency on FruityFoundation.Base
2022-03-31 20:35:36 -04:00

10 lines
309 B
C#

namespace FruityFoundation.Base.Structures;
public static class MaybeExtensions
{
public static Maybe<T> FirstOrEmpty<T>(this IEnumerable<T> col) =>
col.FirstOrDefault() ?? Maybe<T>.Empty();
public static T? ToNullable<T>(this Maybe<T> item) where T : struct =>
item.HasValue ? item.Value : null;
}