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:
parent
336226d686
commit
68bf7bc801
19 changed files with 343 additions and 210 deletions
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue