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
9
votes
2 answers

Is it possible to get the expansion of a single macro instead of the whole file?

I just found How do I see the expanded macro code that's causing my compile error?. Is it possible to get the expansion of a single macro instead of the whole file?
bertfred
  • 412
  • 4
  • 9
9
votes
3 answers

How to use relative git submodule paths in Cargo?

I've done a MuPDF binding for Rust and I want to import it as a crate from its git repository. My Cargo.toml file is something like this: [package] name = "package_name" version = "0.1.0" authors = ["me"] [dependencies] mupdf-sys = {git =…
9
votes
2 answers

Can I make an object public for integration tests and/or benchmarks only?

As suggested by The Book, I have moved the integration tests in my crate to a tests directory. Some of those tests use functions that I don't want to export outside of the crate, though, and I am no longer able to use them in the integration test…
ljedrz
  • 20,316
  • 4
  • 69
  • 97
9
votes
1 answer

How can I prevent Cargo from merging the same dependency with different features?

After figuring out cargo build of the same code: spurious compile time errors?, I want to know how to prevent such a problem: $ cargo new feature_merge $ cargo add nmea $ cargo check > /dev/null 2>&1 && echo "success" success $ cargo add cexpr $…
fghj
  • 8,898
  • 4
  • 28
  • 56
9
votes
1 answer

What is the difference between binaries in ~/.rustup vs ~/.cargo?

I just installed Rust with rustup on MacOS and noticed that there are two rustc and two cargo binaries: ~/.cargo/bin/rustc (cargo) ~/.rustup/toolchains/stable-x86_64-apple-darwin/bin/rustc (cargo) Their versions are exactly the same, but diff…
Zizheng Tai
  • 6,170
  • 28
  • 79
9
votes
0 answers

Get list of active dependencies and their versions during "cargo build"

Some crates offer a pub const &str-version string, some do not. To have a general solution, I need a list of all dependencies and their versions as known to and used by cargo build during compilation so I can build my own const &str of This is my…
user2722968
  • 13,636
  • 2
  • 46
  • 67
9
votes
1 answer

How difficult is it to allow parallel compilation of code with the Rust stable and nightly channels?

The default file-tree created by Cargo allows parallel compilation of release and debug builds as they are located in their own directories; target/release and target/debug, respectively. How difficult is it to also allow parallel compilation of…
PureW
  • 4,568
  • 3
  • 19
  • 27
9
votes
1 answer

No targets specified in the manifest when creating a Cargo workspace

Using Rust 1.11 and Cargo 1.12 (nightly), I'm trying to create a [workspace] which contains a few libraries and a few executables. In my root folder, I added my sub-crates with: cargo new loader cargo new shell --bin I then added the cargo.toml…
BitTickler
  • 10,905
  • 5
  • 32
  • 53
9
votes
1 answer

How to access current cargo profile (build, test, bench, doc, ....) from the build script (build.rs)

I want to write a custom build.rs script that generates some diagrams to accompany the documentation for a crate I'm working on. I want this script to run only when I run cargo doc, not the other profiles (cargo build, cargo test, ...). What would…
adam
  • 791
  • 6
  • 21
9
votes
1 answer

Adding codegen flags to a Cargo build

On Macintosh, to allow some symbols to go unlinked, it is necessary to pass -C link-args='-Wl,-undefined,dynamic_lookup' to the Rust compiler. One needs to do this when building Postgres plugins, because some of the Postgres intrinsics are only…
solidsnack
  • 1,631
  • 16
  • 26
9
votes
1 answer

Is it possible to change the log level for an application at compile time?

Rather than rely on environment variables at runtime, I'd like to compile a debug or release version with non-error log messages stripped out completely. Is it possible to change the log level for an application in the Cargo.toml or via cargo/rustc…
Peter Hall
  • 53,120
  • 14
  • 139
  • 204
9
votes
2 answers

Where does `multirust` install the Rust language source code?

I installed the multirust version of the Rust programming language. I was trying to configure the racer code completion package to point to the Rust source code through the RUST_SRC_PATHenvironment variable. However, I can't seem to find the…
krishnab
  • 9,270
  • 12
  • 66
  • 123
9
votes
2 answers

How can I use a custom module inside a doctest?

mod simulation; use simulation::factory::FactoryType; works fine in main.rs, but not in a doctest inside simulation/factory.rs: impl product_type::ProductType for FactoryType { /// Lorem Ipsum /// /// # Examples /// /// ``` …
wrongusername
  • 18,564
  • 40
  • 130
  • 214
9
votes
1 answer

Json Serialization feature of chrono crate

I'm trying to use DateTime from rust-chrono crate to my own trait. #[derive(Debug, RustcEncodable, RustcDecodable)] pub struct Accomplishment { name: String, accomplishment_type: String, date: DateTime } When I try to compile this it…
Chathurika Sandarenu
  • 1,368
  • 13
  • 25
9
votes
1 answer

Linking to optimised crate from a debug build

I would like to separate some performance intensive code into a .so (I am running Kubuntu Linux) while the main quantity of my code is compiled in debug mode. I want the faster compiles and run time support in my code, but it's unacceptable to run…
stevenkucera
  • 3,855
  • 2
  • 18
  • 13