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

added IParseable interface and applied it to all applicable types

This commit is contained in:
Booklordofthedings 2023-12-13 16:54:23 +01:00
parent 3e8d90d300
commit 0a6062ba02
18 changed files with 169 additions and 18 deletions

View file

@ -3,7 +3,7 @@ using System.Globalization;
namespace System
{
#unwarn
struct UInt16 : uint16, IInteger, IUnsigned, IHashable, IFormattable, IIsNaN
struct UInt16 : uint16, IInteger, IUnsigned, IHashable, IFormattable, IIsNaN, IParseable<uint16, ParseError>, IParseable<uint16>
{
public enum ParseError
{
@ -134,5 +134,19 @@ namespace System
return result;
}
public static Result<uint16, ParseError> IParseable<uint16, ParseError>.Parse(StringView val)
{
return Parse(val);
}
public static Result<uint16> IParseable<uint16>.Parse(StringView val)
{
var res = Parse(val);
if(res case .Err)
return .Err;
else
return .Ok(res.Value);
}
}
}