Skip to content
/ maybe Public

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

License

Notifications You must be signed in to change notification settings

rustedpy/maybe

Repository files navigation

Maybe

Coverage

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

Installation

Latest release:

sh

$ pip install rustedpy-maybe

Latest GitHub master branch version:

sh

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

Python

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