These are chat archives for rust-lang/rust

12th
Sep 2016
Vincent Cantin
@green-coder
Sep 12 2016 00:53
This message was deleted
Igor
@target-san
Sep 12 2016 12:21
@stepancheg Looks to me like definite bug. Like, mutable borrow is widened to the function scope
Tyred
@tyred
Sep 12 2016 12:32
@target-san I think what has happened is that there is a return statement in the match which makes the borrow live as long the function. Correct me if I am wrong, I’m still relatively new to rust :)
Igor
@target-san
Sep 12 2016 12:39
I also suspect this. Though, IMO return shouldn't prolong borrow that far.
Igor
@target-san
Sep 12 2016 12:47
unwrap_or_else does no good - closure needs to consume reference, but it cannot
Tyred
@tyred
Sep 12 2016 12:48

@target-san And alternative is to eliminate the stream borrow in the match and return s.

So Some(_) => return s;

Igor
@target-san
Sep 12 2016 12:51
@stepancheg Am I right that your code sample is in fact smth like this: https://is.gd/ZTqFfo ?
@tyred I suspect that OP wants to produce some mutable reference of possibly different type than the source, but with the same lifetime
And he has two ways to construct it, with the second being default if first one does not return anything useful
Igor
@target-san
Sep 12 2016 13:12
@stepancheg rust-lang/rust#21906 Sad but true.
I hope NLLS will land sooner than later
Vincent Cantin
@green-coder
Sep 12 2016 14:15
I would like to tell you a Rust joke, but I am still trying to make it compile.
Ferdinand Svehla
@fsvehla
Sep 12 2016 14:16
Hah :D Scala at day job, Swift + Rust at home… I feel it as well
Vincent Cantin
@green-coder
Sep 12 2016 15:25
Is this chat room the right place to ask for help when we don't understand something in the language, or is there a better place for that?
I am stuck on a generic iterator which I want to implement only for a specific type of data (on u8). I don't know how to make it work. https://play.rust-lang.org/?gist=0be6520167889dc6061b7545f074d6a9&version=stable&backtrace=0
Vincent Cantin
@green-coder
Sep 12 2016 16:11
I found the answer: impl<I: Iterator<Item=u8>> Iterator for Chunker<I>
mhsjlw
@mhsjlw
Sep 12 2016 20:33
hmm, does anyone know of any crates for building binary structures? instead of manually writing bytes a higher level crate that could let me simply say what message contains what datatypes?
Remi Rampin
@remram44
Sep 12 2016 20:38
mhsjlw: There's serde which is a general serialization/deserialization library with multiple backends
mhsjlw
@mhsjlw
Sep 12 2016 20:40
in this case, i'd be recreating an existing binary protocol so capnproto/serde wouldn't do the trick as much as i'd like it to be :P