rust-cargo

cargo test --release causes a stack overflow. Why doesn't cargo bench?

浪尽此生 提交于 2020-01-11 04:50:06
问题 In trying to write an optimized DSP algorithm, I was wondering about relative speed between stack allocation and heap allocation, and size limits of stack-allocated arrays. I realize there is a stack frame size limit, but I don't understand why the following runs, generating seemingly realistic benchmark results with cargo bench , but fails with a stack overflow when run with cargo test --release . #![feature(test)] extern crate test; #[cfg(test)] mod tests { use test::Bencher; #[bench] fn it

What is a crate attribute and where do I add it?

非 Y 不嫁゛ 提交于 2020-01-08 14:18:09
问题 In order to get a feel for how Rust works, I decided to look at a little terminal-based text editor called Iota. I cloned the repository and ran cargo build only to be told: error: *if let* syntax is experimental help: add #![feature(if_let)] to the crate attributes to enable Where am I supposed to add #![feature(if_let)] to the crate attributes? 回答1: A crate attribute is an attribute ( #[...] ) that applies to the enclosing context ( #![...] ). This attribute must be added to the top of your

Crate cannot find path

↘锁芯ラ 提交于 2020-01-06 12:17:40
问题 I am trying to use this crate to generate an ethereum address: https://docs.rs/ethkey/0.2.5/ethkey/ use ethkey::prelude::*; fn main() { let key = EthAccount::load_or_generate("~/", "passwd") .expect("should load or generate new eth key"); println!("{:?}", key.address()) } This is the example from the documentation and it doesnt seem to work. I get the error below: cargo run Compiling ethkey v0.1.0 (/Users/samueldare/Documents/Code/Thor/ethkey) Finished dev [unoptimized + debuginfo] target(s)

Crate cannot find path

一笑奈何 提交于 2020-01-06 12:17:14
问题 I am trying to use this crate to generate an ethereum address: https://docs.rs/ethkey/0.2.5/ethkey/ use ethkey::prelude::*; fn main() { let key = EthAccount::load_or_generate("~/", "passwd") .expect("should load or generate new eth key"); println!("{:?}", key.address()) } This is the example from the documentation and it doesnt seem to work. I get the error below: cargo run Compiling ethkey v0.1.0 (/Users/samueldare/Documents/Code/Thor/ethkey) Finished dev [unoptimized + debuginfo] target(s)

Crate cannot find path

橙三吉。 提交于 2020-01-06 12:17:04
问题 I am trying to use this crate to generate an ethereum address: https://docs.rs/ethkey/0.2.5/ethkey/ use ethkey::prelude::*; fn main() { let key = EthAccount::load_or_generate("~/", "passwd") .expect("should load or generate new eth key"); println!("{:?}", key.address()) } This is the example from the documentation and it doesnt seem to work. I get the error below: cargo run Compiling ethkey v0.1.0 (/Users/samueldare/Documents/Code/Thor/ethkey) Finished dev [unoptimized + debuginfo] target(s)

Cargo test cannot reference anything public inside the targeting crate in integration test. Unit tests also cannot find test cases

喜欢而已 提交于 2020-01-06 05:48:06
问题 I am trying to do some test on my no_std module but I cannot make both integration and unit test working. I think the cargo does not make functions and modules visible to others. The project is at: https://github.com/ShisoftResearch/Nulloc/tree/e2e15646da79651ddb8c29e0526bad0d60690bec Run cargo test , I got: ➜ cargo test Compiling nulloc v0.1.0 (/Users/shisoft/Dropbox/Code/OSS Projects/Nulloc) error[E0432]: unresolved import `nulloc::bump_heap` --> tests/bump_heap.rs:3:14 | 3 | use nulloc:

How do I generate a text file during compile time and include its content in the output?

混江龙づ霸主 提交于 2020-01-05 11:49:54
问题 I'm trying to do almost the same as How to create a static string at compile time. build.rs use std::{env}; use std::path::Path; use std::io::{Write, BufWriter}; use std::fs::File; fn main() { let out_dir = env::var("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join("file_path.txt"); let mut f = BufWriter::new(File::create(&dest_path).unwrap()); let long_string = dest_path.display(); write!(f, "{}", long_string).unwrap(); } main.rs fn main() { static LONG_STRING: &'static str =

Does Cargo support custom profiles?

自古美人都是妖i 提交于 2020-01-04 03:00:59
问题 I often want to compile in release mode with debug = true so that I can read the generated assembly a bit easier. I am currently doing this: [profile.release] debug = true but I don't want any debug symbols in my final release build. I'd like to do something like: [profile.custom] debug = true opt-level = 3 rpath = false lto = true debug-assertions = false codegen-units = 1 panic = 'unwind' And then run cargo build --custom I've read the documentation to no avail. 回答1: Does Cargo support

Does Cargo support custom profiles?

天大地大妈咪最大 提交于 2020-01-04 02:59:46
问题 I often want to compile in release mode with debug = true so that I can read the generated assembly a bit easier. I am currently doing this: [profile.release] debug = true but I don't want any debug symbols in my final release build. I'd like to do something like: [profile.custom] debug = true opt-level = 3 rpath = false lto = true debug-assertions = false codegen-units = 1 panic = 'unwind' And then run cargo build --custom I've read the documentation to no avail. 回答1: Does Cargo support

How can the compilation properties be determined in a procedural macro?

瘦欲@ 提交于 2020-01-03 18:56:15
问题 I'm working on a procedural macro that does a lot of work that can slow down compilation considerably. The work done does not effect the semantics of the function; that is, if given the same set of arguments, the returned value is does not change depending on whether the macro is applied. In an effort to make the edit-comp-test loop quicker, I would like to make the macro a no-op depending on conditions that relate to how the crate is being compiled. I would like to be able to determine two