Questions tagged [rust-cargo]

Cargo is the official package manager for the Rust programming language.

Cargo is the official package manager for the Rust programming language. Using a manifest, the programmer can provide metadata about a project, including dependencies, which Cargo can automatically download and compile before compiling the project itself.

You can find more information in the cargo book and browse the crates (Rust packages) in crates.io.

2044 questions
0
votes
1 answer

What is the difference between a Struct and an Enum in Rust

Coming from javascript/python I'm used to the idea of classes but am struggling to understand the difference between a Struct and an Enum. For example I can define a 'class' with behaviours in similar ways struct // Defines the StartListen class pub…
userh897
  • 73
  • 7
0
votes
0 answers

launching an executable file from an archive

How to run an executable file from a protected uncompressed archive? I read on various forums, but I did not find an answer in Rust. Found some code but libraries were removed use std::process::{Command, Stdio}; use std::path::Path; use…
0
votes
1 answer

How to run cargo tests sequentially?

There are several tests under proxy/v1_specific. I have to run them in sequential, since these tests have some influence with each other. cargo test --package tests --test proxy v1_specific::test1 cargo test --package tests --test proxy…
calvin
  • 2,125
  • 2
  • 21
  • 38
0
votes
0 answers

Error when adding dependencies to my Rust project: Unable to parse Cargo.toml

I am currently following Phil Opperman's blog to build on a very small OS kernel written in Rust by adding a simple file system. Right now I am trying to get interrupts working for writing to disk, and in the Opperman's blog he recommends adding the…
Hayden Rieder
  • 11
  • 1
  • 4
0
votes
1 answer

Cargo test doesn't find test

I have the tests module outside my src folder and cargo test does not find the test functions inside tests/types/typed.rs cargo clean did not solve the problem
0
votes
0 answers

Rust hyper decoding the response

I am trying to learn web development in rust .And wrote very basic code.Which fetch the data from the url and print the response in log and then returns the response to the service. If you run the below code String::from_utf8 will complain the utf8…
puja
  • 31
  • 3
0
votes
2 answers

Why can't I use clone!() in gtk4 for Rust?

I've just installed gtk4 over gtk for Rust and wrote a hello world program to test if it works. I want to use the clone macro to pass a weak reference for my button but, its not recognising the clone in gtk4::glib and says I have to use gtk::glib…
Shane Gervais
  • 107
  • 12
0
votes
1 answer

How to use the body of a `hyper::Request` without consuming it?

I am trying to read request body using (req.into_body()) and generate a hash key based on parameters (request.uri and request.body) but as documentation states req.into_body() will consume request so I can't use the same variable below that…
nil96
  • 313
  • 1
  • 3
  • 12
0
votes
0 answers

Cargo version problem when building wheel for tokenizer for pip install transformers==3.4.0

I want to use transformers==3.4.0 on a Linux system, and got the error this version of Cargo is older than the `2021` edition, and only supports `2015` and `2018` editions. error: `cargo rustc --lib --message-format=json-render-diagnostics…
11D
  • 1
0
votes
0 answers

What is the correct syntax when using a Cargo workspace dependencies table in a Rust project?

The Cargo documentation for The dependencies table gives the following example: # [PROJECT_DIR]/Cargo.toml [workspace] members = ["bar"] [workspace.dependencies] cc = "1.0.73" rand = "0.8.5" regex = { version = "1.6.0", default-features = false,…
0
votes
0 answers

Is there a way to identify which target is being compiled in a build.rs file?

My cargo.toml is: bin = [ { name = "first", path = "bin/first.rs" }, { name = "second", path = "bin/second.rs" }, ] [lib] name = "some_lib" crate-type = [ "cdylib", "rlib", ] [target."cfg(windows)".build-dependencies] winresource =…
Star
  • 131
  • 3
  • 18
0
votes
1 answer

undeclared crate or module inside `if cfg!(test)` even if defined in dev-dependencies

Here is the error: let tmp = tempdir::TempDir::new("cargo_test").expect("failed to create tempdir"); ^^^^^^^ use of undeclared crate or module `tempdir` My cargo.toml looks like this: #... [dev-dependencies] tempdir = "0.3.7 And in the…
Jitterbug
  • 302
  • 1
  • 11
0
votes
0 answers

Failed to add linker flag to rust project

I want to link the rust project with the flag --no-relax. Here is what I tried: First try: RUSTFLAGS="--cfg aes_force_soft --cfg polyval_force_soft -Clink-args="-Wl,--no-relax"" CARGO_TARGET_DIR=../target cargo xbuild --target x86_64-qkernel.json …
yaoxin jing
  • 55
  • 1
  • 4
0
votes
1 answer

How can Cargo output binary files to the target directory of the current project?

How to output the binary to the target directory of the current project after setting build.target-dir? Currently, all binaries are output to build.target-dir. I know there is the sccache tool, but it still builds and uses more disk space. I have…
0x01
  • 1
  • 1
0
votes
0 answers

Rust cross-compile plotters to x86_64-unknown-linux-musl failed

My project used plotters as dependencies. I want to compile my project to target platform x86_64-unknown-linux-musl from my host platform centos8. Then I met the problems below. Compiling yeslogic-fontconfig-sys v3.2.0 error: failed to run custom…
1 2 3
99
100