Stream: t-compiler/help

Topic: generics


Alex Gaynor (Dec 12 2019 at 02:41, on Zulip):

I have a rather elementary question about the compiler. If you've got crate A, and it instantiates Vec<T>, and then you have crate B, and it _also_ instantiates Vec<T> does the compiler emit Vec<T> in both A and B, or is it able to avoid re-instantiating it in B and just reusing A's?

oli (Dec 12 2019 at 07:55, on Zulip):

It does it in both unless one crate is a dependency of the other

Edd Barrett (Dec 12 2019 at 09:39, on Zulip):

Does that also mean that you get two copies of the code in the end binary?

oli (Dec 12 2019 at 09:51, on Zulip):

link time opimizations usually kill it

Alex Gaynor (Dec 12 2019 at 12:39, on Zulip):

Got it, thanks.

Last update: Apr 05 2020 at 01:35UTC