Crate dependency cylce when using optional dependencies

43 views Asked by At

I have two crate which need functions from each other. I know this is bad practice, but is there a way to do this?

I made two crate with the following configs: for crate A:

[dependencies]
B = {path = "./../B", features = [], optional = true}

[features]
default = ["flag"]
flag = ["dep:B"]

and for crate B:

[dependencies]
A = {path = "./../A", features = [], optional = true}

[features]
default = ["flag"]
flag = ["dep:A"]

But this still give me a cyclic package dependency error. Did i do the features setup wrong?

As extra context, i am trying to make a sudo-webframework. The idea is that one crate is build like normal and that the other one is build using trunk. I have some features and macros setup to turn marked methods into either themself or a sending a tcp packet with the arguments. The goal is to not have the api of a function defined in multiple places.

0

There are 0 answers