rust-cargo

rust compile x86 library on x86_64 machine

穿精又带淫゛_ 提交于 2021-02-19 09:45:29
问题 I have ubuntu x86_64 container and cargo build goes well. But i need to build x86 library version too. As far as I understand i need to add i686 toolchain and target. rustup target add i686-unknown-linux-gnu done successful rustup toolchain install stable-i686-unknown-linux-gnu finished with error $ rustup toolchain install stable-i686-unknown-linux-gnu info: syncing channel updates for 'stable-i686-unknown-linux-gnu' info: latest update on 2018-11-08, rust version 1.30.1 (1433507eb 2018-11

How to opt out of running a doc test?

*爱你&永不变心* 提交于 2021-02-18 19:52:49
问题 I'm writing a Rust library and I want to provide examples in my documentation that compile as part of running cargo test do not run. Is this possible? I'm writing a database client library, and the examples make use of a hypothetical, non-existing database server. As such, the examples always fail when run, but it's important that the examples be valid syntactically. Hence my requirements above. If there's no way to do what I want, then how does one opt out of having cargo test run a specific

How to opt out of running a doc test?

笑着哭i 提交于 2021-02-18 19:51:00
问题 I'm writing a Rust library and I want to provide examples in my documentation that compile as part of running cargo test do not run. Is this possible? I'm writing a database client library, and the examples make use of a hypothetical, non-existing database server. As such, the examples always fail when run, but it's important that the examples be valid syntactically. Hence my requirements above. If there's no way to do what I want, then how does one opt out of having cargo test run a specific

Does rustc / cargo have a -march=native equivalent?

99封情书 提交于 2021-02-16 10:21:28
问题 I feel like binary portability isn't really a concern, and so something like -march=native may always be the default behavior. I can't find anything saying one way or the other though. 回答1: As mentioned in the comments, pass the -C target-cpu option to rustc: rustc -C target-cpu=native For more options: $ rustc -C help ... -C target-cpu=val -- select target processor (rustc --print target-cpus for details) ... See How to pass rustc flags to cargo? for more methods of passing the option. I

How to list a project's source files using the cargo crate?

谁都会走 提交于 2021-02-11 14:37:50
问题 I'm trying to list the source files of a Rust project using the cargo crate. I can not just simply list all the .rs files present in a directory as I want to retrieve exactly the files that the compiler sees during the compilation, which may not be all the .rs files. I'm conducting my experiments on the the Alacritty repository, which has a cargo workspace of 3 projects. Here is my code so far: extern crate cargo; use std::path::Path; use cargo::core::Source; fn main() { let path = Path::new(

Is it possible to compile one specific library with the nightly compiler and link it to a project that is compiled on stable?

老子叫甜甜 提交于 2021-01-28 14:19:02
问题 I am working on a project where a dependency requires a specific nightly feature. I need to use this lib, but I am afraid that if I compile the project with nightly, I could depend on nother libraries that include another unstable feature dependency and I wouldn't be aware of that. Is it possible to compile the library that I need using nightly (while set the nightly version to version that already merged to the release branch) to some kind of "lib.a" file, and compile the whole project on

Is it possible to compile one specific library with the nightly compiler and link it to a project that is compiled on stable?

旧巷老猫 提交于 2021-01-28 14:17:05
问题 I am working on a project where a dependency requires a specific nightly feature. I need to use this lib, but I am afraid that if I compile the project with nightly, I could depend on nother libraries that include another unstable feature dependency and I wouldn't be aware of that. Is it possible to compile the library that I need using nightly (while set the nightly version to version that already merged to the release branch) to some kind of "lib.a" file, and compile the whole project on

How to return a instance of a struct that uses a locally declared variable [duplicate]

↘锁芯ラ 提交于 2021-01-28 11:10:28
问题 This question already has answers here : Is there any way to return a reference to a variable created in a function? (4 answers) Closed 3 years ago . I am trying to figure out how to declare a variable locally and use it in a value that is being returned. The following is the code that is causing the problem use std::io; use std::string::String; use std::io::Write; // Used for flush implicitly use topping::Topping; pub fn read_line(stdin: io::Stdin, prompt: &str) -> String { print!("{}",

How to make a local dependency depend on a feature in Cargo?

三世轮回 提交于 2021-01-27 11:37:43
问题 Given this small library which uses local crates in subdirectories, how would I make one of the dependencies optional, depending on if a feature is enabled? [package] name = "image_load" description = "Small wrapper for image reading API's." version = "0.1.0" [features] default = ["use_png"] [dependencies] [dependencies.image_load_ppm] path = "ppm" # How to make this build _only_ when 'use_png' feature is enabled? [dependencies.image_load_png] path = "png" While I read the documentation, this

error: failed to run custom build command for `openssl v0.9.24`

余生颓废 提交于 2021-01-27 07:16:26
问题 I want to install cargo-apk cargo install cargo-apk to my system (Linux Mint), but I'm getting this error error: failed to run custom build command for `openssl v0.9.24` Caused by: process didn't exit successfully: `/tmp/cargo-install7N44TO/release/build/openssl-65bb03053b1fc095/build-script-build` (exit code: 101) --- stderr thread 'main' panicked at 'Unable to detect OpenSSL version', /home/jiri/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-0.9.24/build.rs:16:14 note: run with