Release/v0.6.0 #12

Merged
rus07tam merged 13 commits from release/v0.6.0 into main 2025-11-26 17:17:42 +03:00
Showing only changes of commit 12c0f42f99 - Show all commits

View file

@ -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):