Decorators
Early return decorators.
early_option(function: OptionCallable[P, T]) -> OptionCallable[P, T]
Decorates the function
returning Option[T]
to handle early returns via the early
(?
in Rust) operator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function |
OptionCallable[P, T]
|
The function to wrap. |
required |
Returns:
Type | Description |
---|---|
OptionCallable[P, T]
|
The wrapping function. |
Source code in src/wraps/early/decorators.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
early_option_await(function: OptionAsyncCallable[P, T]) -> OptionAsyncCallable[P, T]
Decorates the asynchronous function
returning Option[T]
to handle early returns via the early
(?
in Rust) operator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function |
OptionAsyncCallable[P, T]
|
The asynchronous function to wrap. |
required |
Returns:
Type | Description |
---|---|
OptionAsyncCallable[P, T]
|
The asynchronous wrapping function. |
Source code in src/wraps/early/decorators.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
early_result(function: ResultCallable[P, T, E]) -> ResultCallable[P, T, E]
Decorates the function
returning Result[T, E]
to handle early returns via the early
(?
in Rust) operator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function |
ResultCallable[P, T, E]
|
The function to wrap. |
required |
Returns:
Type | Description |
---|---|
ResultCallable[P, T, E]
|
The wrapping function. |
Source code in src/wraps/early/decorators.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
early_result_await(function: ResultAsyncCallable[P, T, E]) -> ResultAsyncCallable[P, T, E]
Decorates the asynchronous function
returning Result[T, E]
to handle early returns via the early
(?
in Rust) operator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function |
ResultAsyncCallable[P, T, E]
|
The asynchronous function to wrap. |
required |
Returns:
Type | Description |
---|---|
ResultAsyncCallable[P, T, E]
|
The asynchronous wrapping function. |
Source code in src/wraps/early/decorators.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|