A Rust-like option type for Python
Project description
A simple Maybe (Option) type for Python 3 inspired by Rust, fully type annotated.
Installation
Not yet available on PyPI. PyPI package coming soon.
Latest GitHub master branch version:
$ pip install git+https://github.com/rustedpy/maybe
Summary
Experimental. API subject to change.
The idea is that a possible value can be either Some(value) or Nothing(), with a way to differentiate between the two. Some and Nothing are both classes encapsulating a possible value.
Example usage,
from rustedpy-maybe import Nothing, Some
o = Some('yay')
n = Nothing()
assert o.unwrap_or_else(str.upper) == 'yay'
assert n.unwrap_or_else(lambda: 'default') == 'default'
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rustedpy-maybe-0.0.0.tar.gz.
File metadata
- Download URL: rustedpy-maybe-0.0.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7737f67186a74ea50db4e2511f1238560047b38a61c5e49b7f7e755b31a6aace
|
|
| MD5 |
989076ae4d52ee9a522670451ea68da2
|
|
| BLAKE2b-256 |
87be64ecd947c8a6016073c8748a5a4a828b45bda5b8887ed7b057c0771f455d
|
File details
Details for the file rustedpy_maybe-0.0.0-py3-none-any.whl.
File metadata
- Download URL: rustedpy_maybe-0.0.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0808636203133c69c1573f8b07c0375dd72b6ab1e5f32ef3ed42295ee63d93d3
|
|
| MD5 |
1064104ac34526cd08a8238585c87a57
|
|
| BLAKE2b-256 |
80d880df2f0a2532216550272b8f58b47554e244efe195869a3071b2f7c42094
|