为Identity添加扩展

This commit is contained in:
Sanchime 2022-05-04 20:26:30 +08:00
parent 115d6766a5
commit df4e7eea7e
1 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,12 @@
using Sanchime.Functional.Core.Products;
namespace Sanchime.Functional.Core.Extensions;
public static class IdentityExtension
{
public static Identity<R> Map<T, R>(this Identity<T> @this, Func<T, R> mapping)
=> () => mapping(@this());
public static Identity<R> Bind<T, R>(this Identity<T> @this, Func<T, Identity<R>> binding)
=> binding(@this()).Invoke();
}