Skip to main content

A Rust-like option type for Python

Project description

GitHub Workflow Status (branch) Coverage

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


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)

Uploaded Source

Built Distribution

rustedpy_maybe-0.0.0-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page