Release/v0.6.0 #12
1 changed files with 6 additions and 6 deletions
|
|
@ -52,21 +52,21 @@ class UniqueType(type):
|
||||||
def map(
|
def map(
|
||||||
cls: type[T],
|
cls: type[T],
|
||||||
value: V | type[T] | T,
|
value: V | type[T] | T,
|
||||||
and_then: Callable[[V], R],
|
or_else: Callable[[V], R],
|
||||||
or_else: Callable[[type[T]], R],
|
and_then: Callable[[type[T]], R],
|
||||||
) -> R:
|
) -> R:
|
||||||
if value is cls or isinstance(value, cls):
|
if value is cls or isinstance(value, cls):
|
||||||
return or_else(cls)
|
return and_then(cls)
|
||||||
return and_then(value) # type: ignore
|
return or_else(value) # type: ignore
|
||||||
|
|
||||||
def and_then(
|
def or_else(
|
||||||
cls: type[T], value: V | type[T] | T, func: Callable[[V], R]
|
cls: type[T], value: V | type[T] | T, func: Callable[[V], R]
|
||||||
) -> type[T] | R:
|
) -> type[T] | R:
|
||||||
if value is cls or isinstance(value, cls):
|
if value is cls or isinstance(value, cls):
|
||||||
return cls
|
return cls
|
||||||
return func(value) # type: ignore
|
return func(value) # type: ignore
|
||||||
|
|
||||||
def or_else(
|
def and_then(
|
||||||
cls: type[T], value: V | type[T] | T, func: Callable[[type[T]], R]
|
cls: type[T], value: V | type[T] | T, func: Callable[[type[T]], R]
|
||||||
) -> R | V:
|
) -> R | V:
|
||||||
if value is cls or isinstance(value, cls):
|
if value is cls or isinstance(value, cls):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue