mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-27 03:58:01 +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;
|
|||
namespace System
|
||||
{
|
||||
#unwarn
|
||||
struct Int : int, IInteger, IHashable, IFormattable, IIsNaN
|
||||
struct Int : int, IInteger, IHashable, IFormattable, IIsNaN, IParseable<int, ParseError>, IParseable<int>
|
||||
{
|
||||
public enum ParseError
|
||||
{
|
||||
|
@ -97,5 +97,19 @@ namespace System
|
|||
return *(Result<int, ParseError>*)&result;
|
||||
}
|
||||
}
|
||||
|
||||
public static Result<int, ParseError> IParseable<int, ParseError>.Parse(StringView val)
|
||||
{
|
||||
return Parse(val);
|
||||
}
|
||||
|
||||
public static Result<int> IParseable<int>.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