These are chat archives for rust-lang/rust

17th
Mar 2017
Robey Pointer
@robey
Mar 17 2017 06:11
i'm sure this is generating efficient code, but it's pretty exhausting to type... good place to consider simplifying the syntax
pub fn make_bottle<I, J, A>(btype: BottleType, header: &Header, streams: I)
  -> impl Stream<Item = Vec<Bytes>, Error = io::Error>
  where
    I: IntoIterator<IntoIter = J, Item = A>,
    J: Iterator<Item = A>,
    A: Stream<Item = Vec<Bytes>, Error = io::Error>
Jacob Kiesel
@Xaeroxe
Mar 17 2017 16:49
Question for the Rust devs: has opt-in telemetry for Rust ever been considered? @nikomatsakis references in https://github.com/rust-lang/rust/pull/37057#issuecomment-269783880 this comment that it'd be useful to have a corpus of data to help make that decision. If given the opportunity I would opt in to telemetry for Rust to help provide that kind of information. Has this been considered before and if so what were the arguments for and against it?
Niko Matsakis
@nikomatsakis
Mar 17 2017 16:50
@Xaeroxe it's long been on the wish list, see also rust-lang-nursery/rustup.rs#254
that said, we do gather a lot of data from crates.io
Jacob Kiesel
@Xaeroxe
Mar 17 2017 16:50
Great! Thanks!
Danilo Silva
@silvadanilo
Mar 17 2017 19:07
Hi folks,
I have a struct (MyStruct) with a status field which is an Enum
An enum value contains an object
I need to match on the status, get a mutable reference to that object, calls a method on it, and in certain case I need to updated the status of MyStruct
The problem is that I cannot update the status field because I have a mutable reference to the value :(
struct MyStruct {
    status: RemoteConnectionState,
}

impl MyStruct {

    match self.status {
        RemoteConnectionState::Connecting(ref mut f) => {
            match f.poll() {
                Ok(Async::Ready(tcp)) => {
                    self.status = RemoteConnectionState::Connected(tcp);
                    Ok(AsyncSink::Ready)
                },
                ....
            }
        }
        .....
    }
    ......
}
error[E0506]: cannot assign to `self.status` because it is borrowed
  --> src/main.rs:97:29
   |
93 |             RemoteConnectionState::Connecting(ref mut f) => {
   |                                               --------- borrow of `self.status` occurs here
...
97 |                             self.status = RemoteConnectionState::Connected(tcp);
   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `self.status` occurs here
there is some way to do this?
do I have to wrap status with some trait helper?
Jacob Kiesel
@Xaeroxe
Mar 17 2017 19:43
I'd define a bool outside of the match self.status statement set it to true inside the match, then after the match if the bool is true set self.status
Yuri
@yurivish
Mar 17 2017 22:12

I have a quick question about rust and glium: it looks from the code and github issues that both nalgebra and cgmath are supported as companion math libraries. Is either one the preferred choice to use?

I'm using Euclid at the moment (https://github.com/servo/euclid), but it doesn't seem there's any way to interface with glium's Attribute system since I am prevented from providing implementations for any glium traits for Euclid's types since I don't control the traits or the types.