mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-25 02:58:02 +02:00
added IParseable interface and applied it to all applicable types
This commit is contained in:
parent
3e8d90d300
commit
0a6062ba02
18 changed files with 169 additions and 18 deletions
|
@ -1,7 +1,7 @@
|
|||
namespace System
|
||||
{
|
||||
#unwarn
|
||||
struct UInt : uint, IInteger, IUnsigned, IHashable, IFormattable, IIsNaN
|
||||
struct UInt : uint, IInteger, IUnsigned, IHashable, IFormattable, IIsNaN, IParseable<uint, ParseError>, IParseable<uint>
|
||||
{
|
||||
public enum ParseError
|
||||
{
|
||||
|
@ -87,5 +87,19 @@ namespace System
|
|||
return *(Result<uint, ParseError>*)&result;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result<uint, ParseError> IParseable<uint, ParseError>.Parse(StringView val)
|
||||
{
|
||||
return Parse(val);
|
||||
}
|
||||
|
||||
public static Result<uint> IParseable<uint>.Parse(StringView val)
|
||||
{
|
||||
var res = Parse(val);
|
||||
if(res case .Err)
|
||||
return .Err;
|
||||
else
|
||||
return .Ok(res.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue