Why is `Infallible` in `core::convert` rather than `core::error`?

As the title suggests.

Seems that it would have made more sense for it to be a general “infallible error” type that everything could use, including third-party code, rather than suggesting it’s just a conversion error.

I skimmed through https://github.com/rust-lang/rust/issues/33417 and the pull-req https://github.com/rust-lang/rust/pull/58302, and I unless I missed something I don’t think this was discussed.

I don’t think it was discussed, but it probably isn’t a big deal- it’s more of a stop-gap replacement for !-as-a-type, until that can be stabilized. And for that matter even if the module is less than intuitive, it’s still usable for general errors.


As it says in the documentation here, Infallible is a temporary type that will be replaced by ! when ! is stabilized. So it doesn’t really matter where it goes.

Infallible was introduced for the sole purpose of stabilizing TryFrom and TryInto, so it was put in core::convert with them to make that more clear, instead of in core::error.

1 Like


Sounds like a good enough reason. :slight_smile:

Other error types are in their modules, e.g. https://doc.rust-lang.org/std/num/struct.ParseIntError.html

1 Like

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