rust

How do I debug a failing cargo test in GDB?

浪尽此生 提交于 2020-11-25 20:52:04
问题 I have a failing Cargo test: $ cargo test [snip] Running target/gunzip-c62d8688496249d8 running 2 tests test test_extract_failure ... FAILED test test_extract_success ... ok failures: ---- test_extract_failure stdout ---- task 'test_extract_failure' panicked at 'assertion failed: result.is_err()', /home/dhardy/other/flate2-rs/tests/gunzip.rs:19 failures: test_extract_failure test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured task '<main>' panicked at 'Some tests failed', /home

How do I debug a failing cargo test in GDB?

只谈情不闲聊 提交于 2020-11-25 20:51:40
问题 I have a failing Cargo test: $ cargo test [snip] Running target/gunzip-c62d8688496249d8 running 2 tests test test_extract_failure ... FAILED test test_extract_success ... ok failures: ---- test_extract_failure stdout ---- task 'test_extract_failure' panicked at 'assertion failed: result.is_err()', /home/dhardy/other/flate2-rs/tests/gunzip.rs:19 failures: test_extract_failure test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured task '<main>' panicked at 'Some tests failed', /home

How do I debug a failing cargo test in GDB?

亡梦爱人 提交于 2020-11-25 20:49:01
问题 I have a failing Cargo test: $ cargo test [snip] Running target/gunzip-c62d8688496249d8 running 2 tests test test_extract_failure ... FAILED test test_extract_success ... ok failures: ---- test_extract_failure stdout ---- task 'test_extract_failure' panicked at 'assertion failed: result.is_err()', /home/dhardy/other/flate2-rs/tests/gunzip.rs:19 failures: test_extract_failure test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured task '<main>' panicked at 'Some tests failed', /home

Why design a language with unique anonymous types?

纵然是瞬间 提交于 2020-11-25 07:27:38
问题 This is something that has always been bugging me as a feature of C++ lambda expressions: The type of a C++ lambda expression is unique and anonymous, I simply cannot write it down. Even if I create two lambdas that are syntactically exactly the same, the resulting types are defined to be distinct. The consequence is, that a) lambdas can only be passed to template functions that allow the compile time, unspeakable type to be passed along with the object, and b) that lambdas are only useful

Why design a language with unique anonymous types?

倖福魔咒の 提交于 2020-11-25 07:26:43
问题 This is something that has always been bugging me as a feature of C++ lambda expressions: The type of a C++ lambda expression is unique and anonymous, I simply cannot write it down. Even if I create two lambdas that are syntactically exactly the same, the resulting types are defined to be distinct. The consequence is, that a) lambdas can only be passed to template functions that allow the compile time, unspeakable type to be passed along with the object, and b) that lambdas are only useful

Why design a language with unique anonymous types?

别来无恙 提交于 2020-11-25 07:26:28
问题 This is something that has always been bugging me as a feature of C++ lambda expressions: The type of a C++ lambda expression is unique and anonymous, I simply cannot write it down. Even if I create two lambdas that are syntactically exactly the same, the resulting types are defined to be distinct. The consequence is, that a) lambdas can only be passed to template functions that allow the compile time, unspeakable type to be passed along with the object, and b) that lambdas are only useful

Do iterators return a reference to items or the value of the items in Rust?

末鹿安然 提交于 2020-11-24 17:50:52
问题 If I have a vector: let mut v = vec![0, 1, 2, 3, 4, 5]; And I iterate through it: for &item in v.iter() {} Would &item here be a reference or a value? It seems like it would be a reference from the & part, but reading the details seem to show it's a value??? 回答1: Do iterators return a reference to items or the value of the items in Rust? There's no general answer to this question. An iterator can return either. You can find the type of the items by looking up the associated type Iterator:

Argument requires that _ is borrowed for 'static - how do I work round this?

风流意气都作罢 提交于 2020-11-24 17:42:13
问题 I have a lifetime/borrowing error from the Rust compiler that I can't get my head around. The problem seems to be that Rust assumes that when an argument is passed to a function that returns a reference to a static value, the argument reference must also be static. #[derive(Debug)] struct TestThingy<'a> { label: &'a str, } const TEST_VALUES: [TestThingy; 3] = [ TestThingy { label: "one" }, TestThingy { label: "two" }, TestThingy { label: "three" }, ]; pub fn value_for_num(num: &str) -> Option