3 ms·
Defining the type as a trait would prevent link-time optimization of library-consumer-side manipulations of data of that type, no? Really, you want a concept t
by derefr 9y ago
Defining the type as a trait would prevent link-time optimization of library-consumer-side manipulations of data of that type, no?
Really, you want a concept that's like a trait, but is explicit about the fact that there's exactly one implementation of the trait, and that that implementation is discoverable at compile time. Less like an interface, more like a C typedef in a third-party-library header file—just without the "header file" part.
- mtanski 9y agoMost Rust compilation is non-incremental but rather one shot with all type information available. Thus, because of LTO optimization either in Rust or LLVM the compiler should discover what the concrete type of the trait is and be able to optimize / inline accordingly.