Skip to content
/ maybe Public
forked from rustedpy/maybe

A simple Rust like Option type for Python 3. Fully type annotated.

License

Notifications You must be signed in to change notification settings

demetere/maybe

 
 

Repository files navigation

Maybe

GitHub Workflow Status (branch) Coverage

A simple Maybe (Option) type for Python 3 inspired by Rust, fully type annotated.

Installation

Latest release:

$ pip install rustedpy-maybe

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

About

A simple Rust like Option type for Python 3. Fully type annotated.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%