These are chat archives for rust-lang/rust

14th
Nov 2018
matrixbot
@matrixbot
Nov 14 2018 03:00
bspeice Is there a way to run a test only in release mode?
bspeice I tried annotating the function with #[cfg(release)], but it's not showing up in cargo test --release
Michal 'vorner' Vaner
@vorner
Nov 14 2018 08:14
I think the closest thing to that is #[cfg(not(debug_assertions))]
Sylwester Rąpała
@xoac
Nov 14 2018 09:34
Hi. Any Idea how to debug this?
test events::desc::tests::test_disabled_desc ... error: process didn't exit successfully: `/home/sylwek/projects/rust_lern/ds/target/debug/deps/ds-b10100af7decf363 --nocapture --test-threads=1` (signal: 11, SIGSEGV: invalid memory reference)
Sylwester Rąpała
@xoac
Nov 14 2018 10:34
Ok. I found it by comment test one by one and find the one that cause this. I use unsafe just in one place to allocate [T; 64] and I changed implementation of T and that couse this SIGSEGV :)
Roman Proskuryakov
@kpp
Nov 14 2018 10:37
Hi. Do wasm crates have to be no_std?
David Vo
@auscompgeek
Nov 14 2018 11:21
@kpp for wasm32-unknown-unknown, yes. emscripten is a different beast.
Roman Proskuryakov
@kpp
Nov 14 2018 11:23
Why is it a different beast?
Let's say I need to use http://libsodium.org/ in my Rust code and compile it to wasm, what steps do I need to do?
Also based on this example https://www.hellorust.com/demos/add/index.html there is no no_std in /add.rs
and suggest what wrong is going on while making tokio work with std::io::BufReader
Code will need to be copied to local machine as playground blocks the outbound connection and result unwrap error will be encountered online
octave99
@octave99
Nov 14 2018 18:33
Oops! have been missing the event loop! Its solved now.
Kelly Thomas Kline
@kellytk
Nov 14 2018 20:48
Which Future combinator would be correct to use at https://github.com/kellytk/x-wstest/blob/arbiter-start/src/main.rs#L77 in lieu of the wait which causes execution to pause and do nothing?
deltavin
@deltavin
Nov 14 2018 21:04

Hi,
I am trying to extract meta values of a webpage and need some help with understanding the compile error ‘borrowed value does not live long enough’

Goal:
For a given webpage, scrape values of description and referrer HTML meta fields, and store the key/values in a hashmap.

Code:
I am able to print the names and values of description and referrer meta fields. However, when I try to store the name/values in a hash map, I get a compile error ‘borrowed value does not live long enough’

The working code that prints the names/values:
https://play.rust-lang.org/?version=beta&mode=debug&edition=2018&gist=305c4ffcd496c3080dd5b9fabed6fcb5

However, I get the compile error if I uncomment the line # 33 - which puts the names and values in the hashmap. I think it is because I am trying to store reference values in the hashmap, but I am unable to connect the lifetimes of the values in the hashmap with the lifetime of parsed_html variable.

Could someone pls explain how to work around this?

Thanks

Lyle Mantooth
@IslandUsurper
Nov 14 2018 21:42
@deltavin, I only needed to change the order things were created and it ran, with that line uncommented.
let meta_selector before let parsed_html because it has to outlive the thing that uses it.
Similarly, let mut relevant_meta_name_values after let all_meta_elements_found, because it contains references to it.

From the compiler error:

= note: values in a scope are dropped in the opposite order they are created

Using Rust 1.30.1
Sylwester Rąpała
@xoac
Nov 14 2018 22:13
Has anyone know a crate that derive API for types like RangeFloat. I mean I suppose this type working like float but with extra bounds when on construction / deserialization
deltavin
@deltavin
Nov 14 2018 22:35

hi @IslandUsurper that fixed it.
I never thought of it from that perspective. I was caught in lifetimes relating to the scope of the function and of the loop. Simply moving let mut relevant_meta_name_values after let parsed_html made it work, even though they are in the same ‘main’ scope.

Thanks