News for hackers. Stuff that matters.
Re:Bare Metal Rust Generics by mlindner on Sunday August 23, 2020 @09:18PM (#24256759)
Wouldn't "dyn" get you the equivalent in Rust? Runtime generics as opposed to compile time.
Re:Bare Metal Rust Generics by steveklabnik on Sunday August 23, 2020 @09:52PM (#24256902)
Nope; dyn is dynamic dispatch, this is statically dispatched.

It is true that dyn means you don't get monomorphization, and can help with binary sizes.

EDIT: thinking about this some more, I wanted to say that it does feel similar, but one big difference that’s easy to explain is that dyn will change the way the value is represented in memory, and this will not. Conceptually, both do “cast and then call this single function”, but in the dyn case, the cast would be to a trait object, whereas this casts directly to &Path.