These are chat archives for rust-lang/rust

Jul 2018
Jul 28 2018 00:14
Anyone want to do a code review? I ported a decision tree from python (original:
The code compiles and works, but I'm sure it can be improved:
Jul 28 2018 02:40
hi I want to have my function accept a reference to slice of types that implmenent Into<String>. I.e. pub fn new_multi<S: Into<String>>(list: &[S]) -> Multi {…}
this works, however I am stuck converting each S into strings… let parts = list
this fails
any ideas
Jul 28 2018 02:49
im guessing the issue is because the iterator returns references to each S. and when doing *item I get a borrow check error because that’s counted as a move?
Jul 28 2018 03:24
@Ichoran I wonder why x as integer_type doesn panic if x doesn't fit into integer_type like integer arithmetics do.
Jul 28 2018 04:11
anyone know how to reset to prev version after rustup update?
Jul 28 2018 06:29
@tandrysyawaludin You can rustup update <concrete-version>
Or rustup toolchain install <channel>-<date>
Andrey Lesnikov
Jul 28 2018 06:32
rustup's readme has a lot of useful info and examples
Jul 28 2018 07:12
okay thanks
Denis Lisov
Jul 28 2018 10:38
@tsoernes Are you interested in feedback in terms of idiomatic code, prediction performance, training performance or what?
Jul 28 2018 18:24
Hey. Im working on this proc macto (derive)
And getting an error on compile
   |          ^^^^^^^^^^^^^^^ expected *-ptr, found u32
Any change to get some code line ? To see the foulty code line generated?
Jul 28 2018 18:32
Something like stack?
Matthias Berndt
Jul 28 2018 19:47
Suppose I have a struct Foo<'a> { foo: &'a Bar }. Now I want to store both a Foo and the Bar that refers to in another struct. How can I do that?
Jul 28 2018 20:35
struct Baz<'a> { foo: Option<Foo<'a>>, bar: Bar }

let mut baz = Baz { foo: None, bar: Bar::new() };
let = Some(Foo { foo: & });
Not that the last line borrows baz for the entire lifetime of baz
Jul 28 2018 20:42
So you can't do &mut baz
And you can't make this into method because with method it will borrow baz mutably for good
Jul 28 2018 21:27
I’m capturing a “foo” inside a map block, this i understand is a borrow. The “foo” generates a reference to something it owns which I want to collect into a vector to be used outside the block. Rust obviously complains the “foo” borrow does not live long enough. Even though it ‘exists’ outside of the block int he first place. Any ideas?
Jul 28 2018 23:06
bspeice You can wrap inside an Rc or Arc so it can be cloned and collected there. No
bspeice Didn't mean to include that last "No", please ignore. Rc or Arc are your best options in this case.