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
rustedpy-maybe-0.0.0.tar.gz
(7.0 kB
view hashes)
Built Distribution
Close
Hashes for rustedpy_maybe-0.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0808636203133c69c1573f8b07c0375dd72b6ab1e5f32ef3ed42295ee63d93d3 |
|
MD5 | 1064104ac34526cd08a8238585c87a57 |
|
BLAKE2b-256 | 80d880df2f0a2532216550272b8f58b47554e244efe195869a3071b2f7c42094 |