Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Generics in crate boundaries
Let's say that we have a crate graph like this:
A exposes
pub fn entry_to_system<A: Trait>(ty: A) {} // This creates lots of generic stuff.
as MIR.
entry_to_system
with the same type, will the compiler need to build the same thing twice?dyn
?In these kinds of cases, would it be better to expose something like
fn entry_to_system<A: Trait>(ty: A) {}
pub struct MyType;
impl Trait for MyType {}
pub fn concrete_entry_to_system(ty: MyType) {
entry_to_system(ty)
}
// or
pub fn dyn_entry_to_system(ty: Box<dyn A>) {
entry_to_system(ty)
}
To avoid these issues?
4 posts - 2 participants
🏷️ Rust_feed