sitegui.dev · 1mo · discuss
Before explaining what the trick is and how it works, I'll take a general example: let's say in a Rust codebase or library you find a better way of doing something, but you still want to keep compatibility with the rest of the codebase or ecosystem. Say you have a new trait Awesome that does what Debug does, but better (for some definition of better). You may want to express code that can consume a value that it either Awesome or Debug like this: fn do_it(value: impl Awesome or Debug) { if impls!(value, Awesome) { // use Awesome's logic }...