OS dependency on Cargo.toml for boxes

I have a rust project where I include the mysql -crate dependency and I want it to be independent.

So I tried: 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 = []

The error is already happening with the minimum main: src / main.rs

fn main () {
}

But the assembly fails. On macos / unix, he always wants to compile the channel and get unauthorized imports:

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`

and the same thing happens on windows for the mysql box itself:

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`

So my question is: how do I handle OS-Dependency in this case?

+4
source share
1 answer

cargo . - # 3195

: , code.

+2

Source: https://habr.com/ru/post/1659038/


All Articles