in2 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- in2/__init__.py +2 -0
- in2/into.py +21 -0
- in2-0.1.0.dist-info/METADATA +10 -0
- in2-0.1.0.dist-info/RECORD +6 -0
- in2-0.1.0.dist-info/WHEEL +4 -0
- in2-0.1.0.dist-info/entry_points.txt +3 -0
in2/__init__.py
ADDED
in2/into.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from typing import Protocol
|
|
2
|
+
|
|
3
|
+
from rezult import Result
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Into[T](Protocol):
|
|
7
|
+
def __into__(self, into: type[T]) -> T:
|
|
8
|
+
raise NotImplementedError
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def into[T](from_: Into[T], to: type[T]) -> T:
|
|
12
|
+
return from_.__into__(to)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TryInto[T, E](Protocol):
|
|
16
|
+
def __try_into__(self, into: type[T]) -> Result[T, E]:
|
|
17
|
+
raise NotImplementedError
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def try_into[T, E](from_: TryInto[T, E], to: type[T]) -> Result[T, E]:
|
|
21
|
+
return from_.__try_into__(to)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: in2
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Easily casting the type of an object.
|
|
5
|
+
Author: Sequence
|
|
6
|
+
Author-email: Sequence <3863887959@qq.com>
|
|
7
|
+
Requires-Dist: rezult>=0.2.1
|
|
8
|
+
Requires-Python: >=3.12
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
in2/__init__.py,sha256=09DvzeRzdbYMEsZFB5WOONQGVFyl_yGFCDoMT9J9MoQ,49
|
|
2
|
+
in2/into.py,sha256=1TaUf916naJqZiPir3bzbzX6aEwK1SSHFzD7oIV9cFM,493
|
|
3
|
+
in2-0.1.0.dist-info/WHEEL,sha256=3NO1oYsF7mANFUWVdyEQLM-zmecczWWEmmF5rEbXrWk,80
|
|
4
|
+
in2-0.1.0.dist-info/entry_points.txt,sha256=tQY6q3VhXMTSuY386kYwsf2awuBzUCKapXTL8otUkls,34
|
|
5
|
+
in2-0.1.0.dist-info/METADATA,sha256=PR-yf-SX42aISBEcT6lJXPHkRwzu8cObXutZbyW_MJ8,248
|
|
6
|
+
in2-0.1.0.dist-info/RECORD,,
|