from_quote and from_numeral return a Try, but not from_interpolation. What if the function detects that the format is incorrect? Should it crash? Or am I missing something?
Btw, I just submitted PR #299 for a code example showing how to create custom literals.
Aurélien Geron said:
from_quoteandfrom_numeralreturn aTry, but notfrom_interpolation. What if the function detects that the format is incorrect? Should it crash? Or am I missing something?
You can choose the return type, so you can make it a Try if you want.
so you can make it a
Tryif you want.
Should I wait to merge the examples PR so that can be shown as well?
oh yeah we should change this
from_interpolation is one of the special ones that gets called at compile time
like from_quote
if you want to make a type that can be built from string interpolation literals
and yeah it should be a Try - can you open an issue for that @Aurélien Geron?
I'm confused, @Richard Feldman : @Anton says we can choose the return type, so it can be a Try if we want to, so why do we need to open an issue?
Btw, what if from_quote or from_numeral can never fail? Should we return Try(Foo, {})?
Anton said:
Should I wait to merge the examples PR so that can be shown as well?
Yes, I'll update the example asap. :+1:
it's better to return Try(Foo, _a)
then you can do the Ok(foo) = ... trick on it
we need an issue for the compiler side of it - to teach the compiler to expect a Try and give a compile-time error if it's Err
I created issue #12044
I also updated the example to mention the fact that from_interpolation will soon require returning a Try, just like from_quote and from_numeral, and the compiler will unwrap Ok and reject Err.
Last updated: Oct 15 2026 at 17:56 UTC