Refactored Option<T> to have opertator lifting and removed ref struct for now.
All checks were successful
Build NuGet / build (push) Successful in 1m43s

This commit is contained in:
2026-08-07 12:58:11 -04:00
parent 1d53af4b46
commit 262b76c4d5
13 changed files with 1123 additions and 262 deletions

View File

@@ -1,17 +1,17 @@
namespace SJK.Functional;
// [Obsolete]
// public class Cache<T> where T : class
// {
// private T? _cache;
// private Func<T> _provider;
// private readonly Func<T, bool>? _isvalid;
public class Cache<T> where T : class
{
private T? _cache;
private Func<T> _provider;
private readonly Func<T, bool>? _isvalid;
// public Cache(Func<T> provider, Func<T, bool>? isvalid = null)
// {
// _provider = provider;
// _isvalid = isvalid;
// }
// public bool IsCached() => _cache is not null;
// public T Value => _cache is null || (_isvalid is not null && !_isvalid(_cache)) ? _cache = _provider() : _cache;
public Cache(Func<T> provider, Func<T, bool>? isvalid = null)
{
_provider = provider;
_isvalid = isvalid;
}
public bool IsCached() => _cache is not null;
public T Value => _cache is null || (_isvalid is not null && !_isvalid(_cache)) ? _cache = _provider() : _cache;
}
// }