mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 12:24:45 +00:00
10 lines
289 B
Python
10 lines
289 B
Python
from _erg_result import Error
|
|
|
|
class Str(str):
|
|
def __instancecheck__(cls, obj):
|
|
return isinstance(obj, str)
|
|
def try_new(s: str): # -> Result[Nat]
|
|
if isinstance(s, str):
|
|
return Str(s)
|
|
else:
|
|
return Error("Str can't be other than str")
|