mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
commit
bff1d657cc
1 changed files with 25 additions and 1 deletions
|
@ -2,14 +2,38 @@ namespace System
|
||||||
{
|
{
|
||||||
struct Boolean : bool, IHashable
|
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";
|
||||||
|
|
||||||
public override void ToString(String strBuffer)
|
public override void ToString(String strBuffer)
|
||||||
{
|
{
|
||||||
strBuffer.Append(((bool)this) ? "true" : "false");
|
strBuffer.Append(((bool)this) ? TrueString : FalseString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetHashCode()
|
public int GetHashCode()
|
||||||
{
|
{
|
||||||
return ((bool)this) ? 1 : 0;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue