Т8
Size: a a a
Т8
Т8
Т8
0
Rust takes a different approach: it monomorphizes all generic types. This means that compiler stamps out a different copy of the code of a generic function for each concrete type needed. For example, if I use a Vec<u64> and a Vec<String> in my code, then the generated binary will have two copies of the generated code for Vec: one for Vec<u64> and another for Vec<String>. The result is fast programs, but it comes at the cost of compile time (creating all those copies can take a while) and binary size (all those copies might take a lot of space).
Т8
Т8
0
fn <impl at src/main.rs:10:1: 12:2>::item(_1: &Foo<T>) -> &T {
debug self => _1; // in scope 0 at src/main.rs:11:13: 11:18
let mut _0: &T; // return place in scope 0 at src/main.rs:11:28: 11:39
bb0: {
_0 = &((*_1).0: T); // scope 0 at src/main.rs:11:28: 11:39
return; // scope 0 at src/main.rs:11:41: 11:41
}
}Т8
Т8