Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: How to import a struct from a crate without importing unused dependencies?
Consider this setup:
// crate A
struct Example { field1: u8, field2: u8 }
impl Example {
fn use_lib() { ... }
}
// crate B
use crateA::Example;
Crate B uses a struct
from crate A that has an associated function that uses a few crate A dependencies. These crate A dependencies that needed in crate B (only the struct
is needed). Is there a way import the struct
from crate A in crate B without importing all the dependencies of crate A?
Solutions I'm considering:
struct
into crate C, create a wrapper in crate A and implement the functions on the wrapperstruct
(without the associated functions) from crate A into crate B. A bit harder if the struct
depends on other structs defined in crate A.Curious to hear other Ideas or thoughts
4 posts - 3 participants
🏷️ Rust_feed