Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix old README example, update docs to highlight Result always contains a value #154

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,12 @@ Access the value directly, without any other checks:

Note that this is a property, you cannot assign to it. Results are immutable.

For your convenience, simply creating an ``Ok`` result without value is the same as using ``True``:

.. sourcecode:: python

>>> res1 = Ok()
>>> res1.value
True
When the value inside is irrelevant, we suggest using ``None`` or a ``bool``,
but you're free to use any value you think works best. An instance of a
``Result`` (``Ok`` or ``Err``) must always contain something. If you're looking for a
type that might contain a value you may be interested in
a `maybe
<https://github.com/rustedpy/maybe>`__.

The ``unwrap`` method returns the value if ``Ok`` and ``unwrap_err`` method
returns the error value if ``Err``, otherwise it raises an ``UnwrapError``:
Expand Down
Loading