Skip to main content

Rusts `Option` and `Result` in Python

Project description

oxypy

Tests

Fully-featured ports of several essential structs from Rust into pure Python

Since true privacy is impossible, inner values of the classes are


Methods

Some methods are deemed unnecessary due to the differences in the languages

Removed Methods:

  • Copy and clone methods
  • Ref and deref methods
  • Unchecked methods
  • Type-dependent methods

Reasons:

  • Methods relating to references are useless due to lack of them in Python.
  • Unchecked methods are unneccessary due to the lac of the unsafe system.
  • Type dependent methods are practically impossible due to the dynamic type system.

Examples

Note: Type annotations are not always necessary, but are done here for brevity

Option

from oxypy import Option

some: Option[int] = Option.some(10)
none: Option[int] = Option.none()

Result

ok: Result[int, str] = Result.ok(10)
err: Result[int, str] = Result.err("An error occured")

Either

from oxypy import Either

left: Either[int, float] = Either.left(42)
right: Either[int, float] = Either.right(3.14159265)

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

oxypy-0.1.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oxypy-0.1.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file oxypy-0.1.0.tar.gz.

File metadata

  • Download URL: oxypy-0.1.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.1

File hashes

Hashes for oxypy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0549f208fe5222f0b4f9ef58fcbd3d420bbd37c0622e6ce69ac6bebb2d750b0d
MD5 4b3beb53066bb1d048230886a6761ce6
BLAKE2b-256 1c66ffb460ba27e7c208fba94517eee9514d468009afb8897e6b55c825d67f6b

See more details on using hashes here.

File details

Details for the file oxypy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: oxypy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.1

File hashes

Hashes for oxypy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b7630f9756575bd8a8ea45e28c6933f029a1feffb8fbd819ced06df952ff3e1
MD5 b57842d39997ac113c1e562489aa7256
BLAKE2b-256 b3287638e9afb6b59cd90d9b030b9e36df15fc13e5af8ab15e310e2a3a4a1686

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page