2022-03-31 20:34:17 -04:00
|
|
|
|
namespace FruityFoundation.Base.Structures;
|
2021-11-19 00:12:02 -05:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|