mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-01 13:56:00 +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
|
@ -3,7 +3,7 @@ using System.Globalization;
|
|||
namespace System
|
||||
{
|
||||
#unwarn
|
||||
struct Int32 : int32, IInteger, ISigned, IHashable, IFormattable, IIsNaN
|
||||
struct Int32 : int32, IInteger, ISigned, IHashable, IFormattable, IIsNaN, IParseable<int32, ParseError>, IParseable<int32>
|
||||
{
|
||||
public enum ParseError
|
||||
{
|
||||
|
@ -188,5 +188,19 @@ namespace System
|
|||
|
||||
return isNeg ? -result : result;
|
||||
}
|
||||
|
||||
public static Result<int32, ParseError> IParseable<int32, ParseError>.Parse(StringView val)
|
||||
{
|
||||
return Parse(val);
|
||||
}
|
||||
|
||||
public static Result<int32> IParseable<int32>.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