Skip to content

Commit

Permalink
Implement core API and update rest of the repo
Browse files Browse the repository at this point in the history
  • Loading branch information
francium committed Aug 27, 2023
1 parent c0c0bd9 commit d28858e
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 536 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include maybe/py.typed
include src/maybe/py.typed
52 changes: 51 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,54 @@
Maybe
======

Experimental. Do not use yet.
======
Result
======

.. image:: https://img.shields.io/github/actions/workflow/status/rustedpy/result/ci.yml?branch=master
:alt: GitHub Workflow Status (branch)
:target: https://github.com/rustedpy/result/actions/workflows/ci.yml?query=branch%3Amaster

.. image:: https://codecov.io/gh/rustedpy/result/branch/master/graph/badge.svg
:alt: Coverage
:target: https://codecov.io/gh/rustedpy/result

A simple Maybe (Option) type for Python 3 `inspired by Rust
<https://doc.rust-lang.org/std/result/>`__, fully type annotated.

Installation
============

Not yet available on PyPI. PyPI package coming soon.

Latest GitHub ``master`` branch version:

.. sourcecode:: sh

$ pip install git+https://github.com/rustedpy/result

Summary
=======

**Experimental. API subject to change.**

The idea is that a result 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,

.. sourcecode:: Python

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
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ vim CHANGELOG.md

4) Do a signed commit and signed tag of the release:
```
git add maybe/__init__.py CHANGELOG.md
git add src/maybe/__init__.py CHANGELOG.md
git commit -S${GPG} -m "Release v${VERSION}"
git tag -u ${GPG} -m "Release v${VERSION}" v${VERSION}
```
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[metadata]
name = maybe
name = rustedpy-maybe
version = attr: maybe.__version__
description = A Rust-like option type for Python
long_description = file: README.rst
Expand Down
4 changes: 0 additions & 4 deletions src/maybe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
SomeNothing,
Maybe,
UnwrapError,
as_async_maybe,
as_maybe,
is_some,
is_nothing,
)
Expand All @@ -16,8 +14,6 @@
"SomeNothing",
"Maybe",
"UnwrapError",
"as_async_maybe",
"as_maybe",
"is_some",
"is_nothing",
]
Expand Down
Loading

0 comments on commit d28858e

Please sign in to comment.