我有一个生锈项目,其中包含mysql - crate依赖项,我想让它独立。
所以我试过了: Cargo.toml
[package]
name = "test"
version = "0.1.0"
authors = ["daMaex"]
[dependencies]
ws = "*"
clap = "*"
env_logger = "*"
[target.'cfg(any(unix, macos))'.dependencies.mysql]
version = "*"
default-features = false
features = ["socket"]
[target.'cfg(windows)'.dependencies.mysql]
version = "*"
default-features = false
features = ["pipe"]
[features]
default = []
ssl = []
错误已经发生在最小的main: src / main.rs
fn main () {
}
但是构建失败了。在macos / unix上,它总是想编译管道并获得一个未解析的导入:
error[E0432]: unresolved import `std::os::windows::io::RawHandle`
--> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/named_pipe-0.2.2/src/lib.rs:38:5
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Could not find `windows` in `std::os`
在Windows上对于mysql crate本身也是如此:
error[E0432]: unresolved import `std::os::unix`
--> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\mysql-7.1.2\src\io.rs:24:5
|
24 | use std::os::unix as unix;
| ^^^^^^^^^^^^^^^^^^^^^ no `unix` in `std::os`
所以我的问题是,在这种情况下我如何处理OS-Dependency?
答案 0 :(得分:2)
这看起来像cargo
错误。
一个相关问题是Cannot declare different version of dependencies in mutually exclusive targets #3195
编辑:这是一个不受支持的功能,而不是根据code的错误。