1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-25 19:18:01 +02:00

Variant TryGet

This commit is contained in:
Brian Fiete 2024-02-22 06:52:11 -05:00
parent 0990537b7e
commit c58f327136

View file

@ -65,6 +65,8 @@ namespace System
}
if (mStructType <= 1)
{
if (mData == 0)
return null;
return Internal.UnsafeCastToObject((void*)mData).GetType();
}
return (Type)Internal.UnsafeCastToObject((void*)(mStructType & ~3));
@ -343,6 +345,15 @@ namespace System
return *(T*)(void*)mData;
}
public bool TryGet<T>(out T value)
{
value = default;
if (VariantType != typeof(T))
return false;
value = Get<T>();
return true;
}
public Result<Object> GetBoxed()
{
if (IsObject)