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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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

Hashes for rustedpy-maybe-0.0.0.tar.gz
Algorithm Hash digest
SHA256 7737f67186a74ea50db4e2511f1238560047b38a61c5e49b7f7e755b31a6aace
MD5 989076ae4d52ee9a522670451ea68da2
BLAKE2b-256 87be64ecd947c8a6016073c8748a5a4a828b45bda5b8887ed7b057c0771f455d

See more details on using hashes here.

File details

Details for the file rustedpy_maybe-0.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rustedpy_maybe-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0808636203133c69c1573f8b07c0375dd72b6ab1e5f32ef3ed42295ee63d93d3
MD5 1064104ac34526cd08a8238585c87a57
BLAKE2b-256 80d880df2f0a2532216550272b8f58b47554e244efe195869a3071b2f7c42094

See more details on using hashes here.

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