Thanks kindly to "Madfrog" (@konnorandrews), who wrote an example of what the generated output code may look like in this Discord message:
trait Test { fn test(&self) { println!("Default impl!"); } } struct Wibble; impl Test for Wibble { fn test(&self) { println!("Wibble!"); } } struct Wobble; impl Test for Wobble { fn test(&self) { println!("Wobble!"); } } fn get_test_value(wibble: bool) -> impl Test { mod __impl_enum { use super::*; pub enum __return { _0(Wibble), _1(Wobble), } impl Test for __return { fn test(&self) { match self { Self::_0(value) => value.test(), Self::_1(value) => value.test(), } } } } if wibble { __impl_enum::__return::_0(Wibble) } else { __impl_enum::__return::_1(Wobble) } } fn main() { get_test_value(true).test(); get_test_value(false).test(); }
(From the Rustlang Discord guild.)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks kindly to "Madfrog" (@konnorandrews), who wrote an example of what the generated output code may look like in this Discord message:
(From the Rustlang Discord guild.)