Simple Result Type for Python 3 inspired by Rust - Fully Type Annotated

2022-04-28

The package provides a Result type for Python 3 inspired by Rust. The idea is that a result value can be either Ok(value) or Err(error), with a way to differentiate between the two. The package encapsulates Ok and Err into two different classes. Result[T, E] is a generic type alias for typing.Union[Ok[T], Err[E]]. It allows you to handle values that can be Ok or Err efficiently, without resorting to custom exceptions. The package provides match statement for python version 3.10 or later, allowing for elegant code. The package implements only the methods that make sense in Python context, and all of this results in type safe access to the contained value when using MyPy to typecheck your code.

Link [ https://github.com/rustedpy/result ]

Previous Article

Simple Result Type for Python 3 inspired by Rust - Fully Type Annotated

2022-04-28

The package provides a Result type for Python 3 inspired by Rust. The idea is that a result value can be either Ok(value) or Err(error), with a way to differentiate between the two. The package encapsulates Ok and Err into two different classes. Result[T, E] is a generic type alias for typing.Union[Ok[T], Err[E]]. It allows you to handle values that can be Ok or Err efficiently, without resorting to custom exceptions. The package provides match statement for python version 3.10 or later, allowing for elegant code. The package implements only the methods that make sense in Python context, and all of this results in type safe access to the contained value when using MyPy to typecheck your code.

Link [ https://github.com/rustedpy/result ]

Copyright © 2024 All rights reserved

Rss

Atom