Release/v0.6.0 #12
1 changed files with 5 additions and 0 deletions
|
|
@ -49,6 +49,11 @@ class UniqueType(type):
|
||||||
raise TypeError(f"{cls} not unwrapped")
|
raise TypeError(f"{cls} not unwrapped")
|
||||||
return value # type: ignore
|
return value # type: ignore
|
||||||
|
|
||||||
|
def unwrap_or(cls: type[T], value: V | type[T] | T, default: R, /) -> V | R:
|
||||||
|
if value is cls or isinstance(value, cls):
|
||||||
|
return default
|
||||||
|
return value # type: ignore
|
||||||
|
|
||||||
def map(
|
def map(
|
||||||
cls: type[T],
|
cls: type[T],
|
||||||
value: V | type[T] | T,
|
value: V | type[T] | T,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue