#try #traits #fallible #result #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

#8 in #fallible

Download history 279/week @ 2022-06-11 196/week @ 2022-06-18 396/week @ 2022-06-25 265/week @ 2022-07-02 365/week @ 2022-07-09 879/week @ 2022-07-16 632/week @ 2022-07-23 563/week @ 2022-07-30 407/week @ 2022-08-06 423/week @ 2022-08-13 271/week @ 2022-08-20 363/week @ 2022-08-27 1046/week @ 2022-09-03 432/week @ 2022-09-10 394/week @ 2022-09-17 271/week @ 2022-09-24

2,247 downloads per month


527 lines

Try Traits

Alternatives to std lib traits that can fail.

TODO: an actual readme. lol.


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


  • nightly
  • nightly_clamp