These are chat archives for rust-lang/rust

3rd
Apr 2018
Michal 'vorner' Vaner
@vorner
Apr 03 2018 09:30
Hello. I want to blacklist a specific version of dependency, but allow both older and newer ones (it temporarily had a breaking change that it reverted, but it seems the version didn't get yanked). But the documentation doesn't list a „not“ operator and this doesn't work :-( futures = "~0.1.11, !0.1.20".
Dylan DPC
@Dylan-DPC
Apr 03 2018 09:50
i don't think cargo has that feature already
Dylan DPC
@Dylan-DPC
Apr 03 2018 10:38
@vorner why not have 0.1.21 as the minimum version?
Michal 'vorner' Vaner
@vorner
Apr 03 2018 10:50
Because all the older versions work fine too and forcing newer versions onto users of the library seems a bit wrong?
I'll do that if need be, but just blacklisting that one version seemed like a better alternative.
Andrey Lesnikov
@ozkriff
Apr 03 2018 10:52
I think it's better to create an issue in https://github.com/rust-lang/cargo/issues
Denis
@mexus
Apr 03 2018 10:54
wouldn't it be better to just yank the bugged version? :)
Dylan DPC
@Dylan-DPC
Apr 03 2018 10:55
or that
Denis
@mexus
Apr 03 2018 10:57
btw are you sure that 0.1.20 contains the breaking change?
and not 0.1.19?
i believe 0.1.20 is reverting a breaking change that has been done in 0.1.19
Michal 'vorner' Vaner
@vorner
Apr 03 2018 10:58
No, the revert didn't work. Another revert was done in .21. I'm pretty sure of that.
Denis
@mexus
Apr 03 2018 10:58
rust-lang-nursery/futures-rs@c5c976d
but nevertheless i'd rather create an issue in that repo
(Context: macro_rules)
Roman Proskuryakov
@kpp
Apr 03 2018 12:46
How do I use epoll in emscripten?
or how do I add target for emscripten with musl support?
Ingvar Stepanyan
@RReverser
Apr 03 2018 19:23
@WaDelma can you show your macro?
apiraino
@apiraino
Apr 03 2018 22:42
Hi, I'm doing my first tests with the Tokio library and the Future mechanism to trigger async tasks (async newbie)
in that snippet there are two async tasks (io::write_all and io::read_to_end)
in the first one the println statement actually prints something on stdout, the second future one does not print anything
running with tokio 0.15 and rust 1.25
I suspect that's a trivial thing but why is that?
Denis
@mexus
Apr 03 2018 22:47
could you replace res with (_, res) (line 24) and try it out again?
apiraino
@apiraino
Apr 03 2018 22:54
uhm ... I see what you mean. however it complains that it expects a Result:
std::result::Result<(tokio::net::TcpStream, &str), std::io::Error>
should it be then .then(|(_, res)| {...}?
Denis
@mexus
Apr 03 2018 22:56
ah, sorry
            let handle_conn = io::read_to_end(sock, buf).and_then(|(_, res)| {
                println!("Got: '{:?}'", res);
                // ^^^ this statement prints nothing on stdout
                Ok(())
            }).map_err(|e| println!("Got error while reading: {}", e));
apiraino
@apiraino
Apr 03 2018 22:59
uhm ... interesting, it works. Why do I have to chain a map_err() after the and_then (without that the compiler complaints)
Denis
@mexus
Apr 03 2018 22:59
btw it works for me even with the initial variant
give it another try :)
apiraino
@apiraino
Apr 03 2018 23:01
right, using and_then instead of then these println work
Denis
@mexus
Apr 03 2018 23:01
i mean it works for me with your paste
with then
btw you don't have to use map_err with then because you return Ok(()), effectively making the associated Error to be a unit (())
(actually the compiler infers that type to be a unit)
apiraino
@apiraino
Apr 03 2018 23:05
ah ok
however I can't make work what works for you, I'm getting confused
this doesn't print anything:
         let handle_conn = io::read_to_end(sock, buf)                                                                        
             .and_then(|(_, res)| {                                                                                          
                 println!("Got: '{:?}'", res);                                                                               
                 Ok(())                                                                                                      
             })                                                                                                              
             .map_err(|err| println!("ouch: {:?}", err));                                                                    
Denis
@mexus
Apr 03 2018 23:07
how do you test it?
apiraino
@apiraino
Apr 03 2018 23:07
compile and run locally
then run telnet localhost 6601, then write something
Denis
@mexus
Apr 03 2018 23:08
then write.. and then?
this read_to_end will provide you a result only when the stream terminates
so you have to close your telnet
Connected to localhost.
Escape character is '^]'.
dsaddas
^]
telnet> quit
apiraino
@apiraino
Apr 03 2018 23:10
damn you're right
I also had this problem using io::copy. I'll try again
I can't get any echo on the console. Now I suppose this is because of the socket
Denis
@mexus
Apr 03 2018 23:14
i believe copy should work right away
because doesn't buffer anything AFAIK
and yes, it works for me :)
every time I hit enter in telnet i'm getting the reply
apiraino
@apiraino
Apr 03 2018 23:16
oh my (-: I must be tired
yes I get the local echo too, but none of those println statements
Denis
@mexus
Apr 03 2018 23:16
accepted socket; addr=V4(127.0.0.1:59622)
wrote (12, ReadHalf { handle: BiLock { inner: Inner { state: AtomicUsize(0), inner: Some(UnsafeCell) } } }, WriteHalf { handle: BiLock { inner: Inner { state: AtomicUsize(0), inner: Some(UnsafeCell) } } }) bytes
wrote message; success=true
on the telnet side:
Connected to 127.0.0.1.
Escape character is '^]'.
adsasadas
adsasadas
^]
telnet> 
Connection closed.
apiraino
@apiraino
Apr 03 2018 23:18
ok, again when we shut dwon the socket
Denis
@mexus
Apr 03 2018 23:18
but yes, the final printout happens only when the stream terminates
well yes, the closure is then is executed only when io::copy finishes... and it does so when the stream is closed :)
(also map)
apiraino
@apiraino
Apr 03 2018 23:19
uhm ... I need to understand better this
so maybe I can have an immediate print writing to the stream and immediately flushing?
well, ignore what I wrote. these are 2 different things
io::copy returns only when EOF has been hit
by returns i mean its poll() returns Ready
apiraino
@apiraino
Apr 03 2018 23:25
uhm ... I see. I thought (wrongly) the EOF on a TCP stream finished when I hit enter
maybe reading a fixed-size Vector of bytes with read instead of waiting for EOF behaves differently
anyway, things are a bit clearer now; thanks for the explaination @mexus