3 ms·
Thanks, that's an interesting read. indeed a developer can use that trick "in the case of conversion traits". Monomorphization seems to be the source of 2 maj
by vmarsy 8y ago
Thanks, that's an interesting read.
indeed a developer can use that trick "in the case of conversion traits".
Monomorphization seems to be the source of 2 major problems: compile time, and binary size.
An optimization that could reduce the compile time by caching the generated code (at least when compiling over-and-over the same code base. i.e. "Incremental compilation") - and it seems that Rust already is doing something with it [1]. I wonder if something specific is done for template instantiations there.
Optimizations aimed at reducing binary size seems much more tricky, if not impossible, except as you pointed out in the limited cases described above. In the regular cases, templates are kind of working as intended: the developer has to think if he/she would have written the same amount of code N times if templates were non existent.
[1] https://blog.rust-lang.org/2016/09/08/incremental.html https://blog.rust-lang.org/2016/09/08/incremental.html