chromium / subspace

A concept-centered standard library for C++20, enabling safer and more reliable products and a more modern feel for C++ code.; Also home of Subdoc the code-documentation generator.
https://suslib.cc
Apache License 2.0
89 stars 15 forks source link

TryFrom<ToType, FromType> should be satisfied for all From<ToType, FromType> #417

Open danakj opened 10 months ago

danakj commented 10 months ago

Rust provides blanket impl of TryFrom when From is satisfied: https://doc.rust-lang.org/stable/src/core/convert/mod.rs.html#762 which returns an error type of Infallible.

Similarly, sus::construct::TryFrom should be satisfied, and it should be possible to call try_from. We can provide an overload which does the same and returns Result<ToType, Infallible>.