how can i have crate that depend on with feature use another version of same crate like below
[features]
serde_1 = ["dep_serde_1"]
serde_1_0_133 = ["dep_serde_1_0_133"]
[dependencies]
dep_serde_1 = { package = "serde", version = "1.0.0", optional = true}
dep_serde_1_0_133 = { package = "serde", version = "1.0.133", optional = true}
my problem is compiler force me to use
use dep_serde_1::*;
except like this
use serde::*;
i just enable one of them at time and in code with cfg(feature = serde_1) i'll chose what code must compile
sorry about my poor English
[Edit]
main idea drive form this problem, for example if my model use actix-0.10 and another crate that use my lib use actix-0.12 it generate compiler error
I'm not quite sure I understand what you want. If you want the name of the crate to be
serdein your use statements, you can rename them back:[Edit:] The above takes care of your use of serde, but
serde_derivehas its own ideas. When you define a struct likeserde generates code that looks roughly like this:
i.e. it ignores the renaming of the serde crate and tries to use the crate by its original name.
You can override this behavior with the
cratecontainer attribute:which will make the generated code use the serde from the outer namespace:
Note, that mutually exclusive features are not a good idea. If you can, it's better to make one the default and the other to override it.
I'm also not sure your cargo dependencies are actually doing what you want them to. Cargo doesn't allow depending on a crate twice, and if I force
dep_serde_1to=1.0.0cargo will complain that there is a conflict.