1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-16 07:14:09 +02:00
Beef/BeefLibs/corlib/src/Boolean.bf

45 lines
812 B
Beef
Raw Normal View History

2019-08-23 11:56:54 -07:00
namespace System
{
struct Boolean : bool, IHashable
{
//
// Public Constants
//
// The public string representation of true.
public const String TrueString = "True";
// The public string representation of false.
public const String FalseString = "False";
2019-08-23 11:56:54 -07:00
public override void ToString(String strBuffer)
{
strBuffer.Append(((bool)this) ? TrueString : FalseString);
2019-08-23 11:56:54 -07:00
}
2021-12-28 09:44:25 -05:00
public static int operator<=>(Boolean a, Boolean b)
{
return (SelfBase)a <=> (SelfBase)b;
}
2020-02-18 08:41:14 -08:00
public int GetHashCode()
2019-08-23 11:56:54 -07:00
{
return ((bool)this) ? 1 : 0;
}
public static Result<bool> Parse(StringView val)
{
if (val.IsEmpty)
return .Err;
if (val.Equals(TrueString, true))
return true;
if (val.Equals(FalseString, true))
return false;
return .Err;
}
2019-08-23 11:56:54 -07:00
}
}