#fallible #traits #try #result #stdlib #tryfrom

no-std try-traits

Alternatives to std lib traits that can fail

2 releases

0.1.1 Aug 18, 2020
0.1.0 Aug 18, 2020

#2239 in Rust patterns

Download history 832/week @ 2024-03-13 517/week @ 2024-03-20 526/week @ 2024-03-27 693/week @ 2024-04-03 328/week @ 2024-04-10 671/week @ 2024-04-17 1090/week @ 2024-04-24 1615/week @ 2024-05-01 1184/week @ 2024-05-08 1848/week @ 2024-05-15 1270/week @ 2024-05-22 1343/week @ 2024-05-29 1497/week @ 2024-06-05 1243/week @ 2024-06-12 1306/week @ 2024-06-19 749/week @ 2024-06-26

5,001 downloads per month

MIT/Apache

25KB
527 lines

Try Traits

Alternatives to std lib traits that can fail.

TODO: an actual readme. lol.


lib.rs:

Fallible versions of the std lib's traits.

For most cases, these traits are probably not what you need, and simply with careful use of generics you can use the builtin variants. And, when you can't, it's preferred to write "try" functions directly, such as File's try_clone method.

Instead, these are meant to be used in APIs that require the ability to abstract over operations that could be fallible.

Why Some Traits Weren't Included

There's a few reasons a core trait might not have been included:

  • They already completely support a form of failibility, and as such it wouldn't make sense to add a try version of them. (examples: FromStr).
  • Traits that it doesn't make much sense for them to be failible, such as core::marker traits like Copy and Send.
  • They simply hadn't been released yet when this was written. If this is the case, file an issue (or submit a pull request!)

No runtime deps

Features