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
8
votes
1 answer

How to see rest of "and X others" in rustc error message?

Sometimes when you have an error, e.g. about what other types implement a trait, you'll see an error message like this: error[E0277]: the trait bound `Vec: ToHeader` is not satisfied --> src/main.rs:3:35 | 3 | #[derive(Clone, Debug,…
Daniel Porteous
  • 5,536
  • 3
  • 25
  • 44
8
votes
3 answers

Failed to select a version for the requirement `rand = "^0.9.0"`

I am getting this error every time while running cargo build: error: failed to select a version for the requirement `rand = "^0.9.0"` candidate versions found which didn't match: 0.8.5, 0.8.4, 0.8.3, ... location searched: crates.io index required…
AdwaitDash
  • 83
  • 1
  • 3
8
votes
3 answers

How to generate documentation for modules that are behind #[cfg(test)]?

In a Rust project there is a module with utilities to support testing, packed in a module test_utils: #[cfg(test)] pub mod test_utils; Is there a way to make cargo doc generate also the documentation for test_utils module and the things inside?
Sergey Potapov
  • 3,819
  • 3
  • 27
  • 46
8
votes
2 answers

Need to extract the last word in a Rust string

I am doing some processing of a string in Rust, and I need to be able to extract the last set of characters from that string. In other words, given a string like the following: some|not|necessarily|long|name I need to be able to get the last part…
Factor Three
  • 2,094
  • 5
  • 35
  • 51
8
votes
3 answers

How I can get coverage for cargo test?

When I want to test C++ coverage, I can build my program with -fprofile-arcs -ftest-coverage, run all tests, and run gcov to get coverages. However, when it comes to Rust, I get totally lost. What I want to do is run the following tests(on my Mac),…
calvin
  • 2,125
  • 2
  • 21
  • 38
8
votes
2 answers

How to download another private repository in Github Actions with Cargo?

Problem I have a private Rust project (A) and it depends on another private Rust project (B). On my local machine, it works because I am logged into git. I am not sure how to login into git in Github Actions. I am not sure if it's needed. I am…
NoKey
  • 129
  • 11
  • 32
8
votes
2 answers

what is the command to update all my rust packages

I installed several rust applications using: cargo install fd-find sd ripgrep rga bat tealdeer exa git-delta du-dust Is there any command like sudo apt update && sudo apt upgrade which I can use to update the packages.
Ahmad Ismail
  • 11,636
  • 6
  • 52
  • 87
8
votes
1 answer

Why isn't Rust linker faster with incremental builds?

I'm new to Rust and I'm trying to understand why can't Rust build faster. I'm specifically talking about the most common case, where I've made a small change in one of my source files and then I need to wait seconds for the cargo build to do its…
at54321
  • 8,726
  • 26
  • 46
8
votes
1 answer

Cannot compile Rust project, linking with `cc` failed

I forked a repository and modified it a bit. The crate compiles by its own, and all the tests pass. However, I cannot get it to build when I attempt to use it in another project. The package is at https://github.com/tvallotton/cryptomkt-rs. When I…
Tomás Vallotton
  • 538
  • 6
  • 13
8
votes
2 answers

Generating constants ar compile time from file content

Let's say I have a file with some constants in it. This file probably comes from a different service and might be different for different scenarios. Now I want to squeeze every last bit of performance out of my program, want the compiler to do as…
Tristan Storch
  • 690
  • 8
  • 18
8
votes
1 answer

Dead code warning with multiple binaries?

I noticed that in order for a piece of code to not be classified as dead, it has to be reachable from all binaries. Example: Cargo.toml: [[bin]] name = "main_one" path = "src/main_one.rs" [[bin]] name = "main_two" path =…
Vilda
  • 1,675
  • 1
  • 20
  • 50
8
votes
2 answers

What target-features uses rustc by default?

There are some target-features which can be used by adding parameter -C target-feature=+sse,+avx to compiler. Available features can be shown using rustc --print target-features. There are also some default activated features, for example, SSE on…
8
votes
3 answers

Why would a cross-compilation build fail on openssl when openssl is not in the dependency graph?

When building my Rust lambda using cross, I get this error: error: failed to run custom build command for `openssl-sys v0.9.58` When I look at my dependency graph, openssl isn't even listed! How is this happening? Here is my Cargo.toml…
tcmoore
  • 1,129
  • 1
  • 12
  • 29
8
votes
1 answer

How to stop `cargo clippy` from running on dependencies as well?

I have a workspace with many crates. I want to run cargo clippy only one of of them them and not any of its dependencies. How do I accomplish this?
user855
  • 19,048
  • 38
  • 98
  • 162
8
votes
1 answer

how to install +nightly (whatever that means) so I can run cargo expand

I don't want to use anything but the stable toolchain for my normal work but would like to be able to debug my macros using expand. I don't even now how to use anything but the default stable tool chain.
pm100
  • 48,078
  • 23
  • 82
  • 145