# Simplify \`Try\` for better code reuse

**URL:** <https://internals.rust-lang.org/t/simplify-try-for-better-code-reuse/7488>\
**Category:** libs\
**Created:** [May 10, 2018, 1:39pm UTC](https://internals.rust-lang.org/t/simplify-try-for-better-code-reuse/7488 "2018-05-10T13:39:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soni](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@Soni](https://internals.rust-lang.org/u/Soni)\
**Post date:** [May 10, 2018, 1:39pm UTC](https://internals.rust-lang.org/t/simplify-try-for-better-code-reuse/7488/1 "2018-05-10T13:39:10Z")

</div>

I think it would be a good idea to “deprecate” (remove) `Try::from_ok` in favor of `.into()`, and have `From<T>` for `Result<T, E>`.

I can’t think of any case where this can be an issue. We just need to add an additional constraint on `Try`: `where Self::Ok: Into<Self>`, maybe? (I’m not sure if this constraint is correct)

This keeps `Try` simpler and encourages code reuse. Code reuse is a big deal for me, as it keeps implementations simple, without affecting expressive power. (Personally I can’t come up with a case where you can’t use `Try` + `into` as a replacement for `Try` + `from_ok`)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 25, 2019, 8:30am UTC](https://internals.rust-lang.org/t/simplify-try-for-better-code-reuse/7488/2 "2019-03-25T08:30:11Z")

</div>

Closed on March 25, 2019, 8:30am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
