1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-16 23:34:10 +02:00

Added nullable(T), Result<T> can use null conditionals

This commit is contained in:
Brian Fiete 2020-04-27 15:09:10 -07:00
parent 336226d686
commit 68bf7bc801
19 changed files with 343 additions and 210 deletions

View file

@ -50,6 +50,15 @@ namespace System
return default(T);
}
public static nullable(T) operator?(Self val)
{
switch (val)
{
case .Ok(let inner): return inner;
case .Err: return null;
}
}
[SkipCall]
public void Dispose()
{
@ -84,6 +93,18 @@ namespace System
}
}
/*extension Result<T> where T : class
{
public static T operator?(Self val)
{
switch (val)
{
case .Ok(let inner): return inner;
case .Err: return default;
}
}
}*/
enum Result<T, TErr>
{
case Ok(T val);
@ -138,6 +159,15 @@ namespace System
return default(T);
}
public static nullable(T) operator?(Self val)
{
switch (val)
{
case .Ok(let inner): return inner;
case .Err: return null;
}
}
[SkipCall]
public void Dispose()
{