These are chat archives for rust-lang/rust

18th
May 2018
Hans W. Uhlig
@huhlig
May 18 2018 00:14
@brandonros looks like the only way is still https://crates.io/crates/odbc
Brandon Ros
@brandonros
May 18 2018 03:25
@huhlig
would ODBC be performant?
trsh
@trsh
May 18 2018 06:46
Hi guys! Is there some way do debug a macro?
For Extern crate?
trsh
@trsh
May 18 2018 06:51
"note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)" > could not find any usable info how to do this
Michal 'vorner' Vaner
@vorner
May 18 2018 06:56
cargo-expand could maybe help
trsh
@trsh
May 18 2018 06:56
When I try it says > error: unknown -Z flag specified: external-macro-backtrace
Michal 'vorner' Vaner
@vorner
May 18 2018 06:56
depends on how serious the error is
trsh
@trsh
May 18 2018 06:56
It's ajoke?
One error message suggests and flag, another says one is not real
Michal 'vorner' Vaner
@vorner
May 18 2018 06:57
The -Z one is only on nightly
trsh
@trsh
May 18 2018 06:57
@vorner I looked into cargo-expand, and don't understand how to use it
cargo +nightly run -Z external-macro-backtrace
error: unknown `-Z` flag specified: external-macro-backtrace
this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
Michal 'vorner' Vaner
@vorner
May 18 2018 06:58
You install it, then say cargo expand and it produces source code after all the macros expanded
trsh
@trsh
May 18 2018 06:59
Rust devs ar making April fools?
@vorner where it's produced?
cargo expand
error: extra arguments to `rustc` can only be passed to one target, consider filtering
the package by passing e.g. `--lib` or `--bin NAME` to specify a single target
cat: /tmp/cargo-expand1cPzfc/expanded: No such file or directory
apiraino
@apiraino
May 18 2018 07:08
@trsh I don't use cargo expand but that error has been reportend on their github issue tracker:
dtolnay/cargo-expand#24
(not sure if related to your case)
trsh
@trsh
May 18 2018 07:09
cargo expand --lib manu
   Compiling manu v0.1.0 (file:///home/trsh/manu/backEnd2/manu)
error: the option `Z` is only accepted on the nightly compiler
LOL
So nightly again
A now one of libs dies with nightly rust
Dead end
trsh
@trsh
May 18 2018 07:15
Put an answer for that issue 24
Ghost
@ghost~5abda813d73408ce4f93b6bf
May 18 2018 09:12
hello
Denis Lisov
@tanriol
May 18 2018 09:30
Hello!
@trsh external-macro-backtrace is a rustc option, while you're trying to use it directly with cargo. It should be used as
cargo +nightly rustc -- -Z external-macro-backtrace
trsh
@trsh
May 18 2018 09:41
@tanriol ok. Tnx
@girng hello godot face
Denis Lisov
@tanriol
May 18 2018 09:51
@trsh Submitted an issue rust-lang/cargo#5546 to suggest a working syntax for rustc unstable options
tandrysyawaludin
@tandrysyawaludin
May 18 2018 10:09
@berkus how to make simpler?
ozgurakkurt
@ozgurakkurt
May 18 2018 12:54
Hi, I want to split a BytesMut from bytes crate at the position of last b"\r\n". Does anyone know how can I do this efficiently
@tanriol thanks
abirmar
@abirmar
May 18 2018 13:51
Hey guys, I think that's also a general potential rust question.
I'm having an issue with moving out of borrowed content
Which is in itself already a problem but I can't think of a solution right now
 --> src/main.rs:72:21
   |
72 |                     lock.read().unwrap().get(&1).unwrap().send(data)
   |                     ^^^^ borrowed value does not live long enough
73 |                 })
   |                 - `lock` dropped here while still borrowed
   |
   = note: values in a scope are dropped in the opposite order they are created

error[E0507]: cannot move out of borrowed content
  --> src/main.rs:72:21
   |
72 |                     lock.read().unwrap().get(&1).unwrap().send(data)
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content

error: aborting due to 2 previous errors

Current server future is

    let server = listener
        .incoming()
        .map(move |socket| {
            let lock = shared_channels.clone();
            println!("accepted socket; addr={:?}", socket.peer_addr().unwrap());

            io::read_exact(socket, [0_u8; 10])
                .map(|(_, buf)| buf)
                .map(|buf| {
                    let rec_str = str::from_utf8(&buf).unwrap();
                    println!("Received: {:?}", &rec_str);
                    String::from(rec_str)
                })
                .map( move |data| {

                    lock.read().unwrap().get(&1).unwrap().send(data)
                })
        })
        .buffer_unordered(20)
        .for_each(|_| Ok(()))
        .map_err(|err| {
            println!("accept error = {:?}", err);

This will be spawned as a 'server' on a threadpool with several 'clients'. lock is Arc<RwLock<HashMap<i32, mpsc::Sender<String>>>>, my senders to the receivers therefore.

Maciej Gorywoda
@makingthematrix
May 18 2018 13:59
@apiraino I moved to Berlin from Warsaw a year ago and I'm also trying to learn German. English and French are sooo much easier :)
abirmar
@abirmar
May 18 2018 14:00
I think I understand why that could be a problem but thought I had properly dealt with it.
lock is cloned, e.g. the ref counter is increased and I create a 'thread-local' reference to it with lock and should not be borrowed. This is passed via moveinto the most inner map. But here the compiler complains that I move lock out there again...?
Andreas Rottmann
@rotty
May 18 2018 14:23
I have a question about reference mutability in a C API wrapper: erickt/rust-zmq#216. Anyone care to give a second opinion?
Andy Bell
@Andy-Bell
May 18 2018 15:40

having an issue with Hyper requests from a client. Code:

let uri = "".parse().unwrap();
let mut req = Request::new(Method::Post, uri);
req.headers_mut().set(ContentType::json());
req.headers_mut().set(ContentLength(json.len() as u64));
 req.set_body(json);

let work = client.request(req).and_then(|res{
    //do things with response
)};

error I get is:

^^^^^^^^ the trait `std::ops::FnOnce<(hyper::Response,)>` is not implemented for `()`
this code seems to be the same as in the “advanced client” example for hyper (https://hyper.rs/guides/client/advanced/)
Berkus Decker
@berkus
May 18 2018 17:48
@tanriol hmm.. yeah, only i can't figure how owning_ref would work here; any hint/tutorial?
@trsh just switch to a slightly older nightly version
Berkus Decker
@berkus
May 18 2018 17:53
@tandrysyawaludin something like use supplier_module; ... .mount("/suppliers", routes![supplier_module::read_all_suppliers]...
David James
@xpe
May 18 2018 22:44
BTW, http://rustconf.com/program.htm is broken (at least for me)
Hmm, when I go back and follow the front-page link, I see that http://rustconf.com/program.html works (with the final "l")