These are chat archives for rust-lang/rust

28th
Jul 2018
tsoernes
@tsoernes
Jul 28 2018 00:14
Anyone want to do a code review? I ported a decision tree from python (original: https://github.com/zotroneneis/machine_learning_basics/blob/master/decision_tree_regression.ipynb).
The code compiles and works, but I'm sure it can be improved: https://github.com/tsoernes/machine_learning_basics/blob/master/src/decision_tree_regression.rs
rebo
@rebo
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
.iter()
.map(|item|
item.into(),
)
this fails
any ideas
rebo
@rebo
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?
Zakarum
@omni-viral
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.
tandrysyawaludin
@tandrysyawaludin
Jul 28 2018 04:11
anyone know how to reset to prev version after rustup update?
Zakarum
@omni-viral
Jul 28 2018 06:29
@tandrysyawaludin You can rustup update <concrete-version>
Or rustup toolchain install <channel>-<date>
Andrey Lesnikov
@ozkriff
Jul 28 2018 06:32
rustup's readme has a lot of useful info and examples
tandrysyawaludin
@tandrysyawaludin
Jul 28 2018 07:12
okay thanks
Denis Lisov
@tanriol
Jul 28 2018 10:38
@tsoernes Are you interested in feedback in terms of idiomatic code, prediction performance, training performance or what?
trsh
@trsh
Jul 28 2018 18:24
Hey. Im working on this proc macto (derive)
And getting an error on compile
#[derive(json_fedex_bind)]
   |          ^^^^^^^^^^^^^^^ expected *-ptr, found u32
Any change to get some code line ? To see the foulty code line generated?
trsh
@trsh
Jul 28 2018 18:32
Something like stack?
Matthias Berndt
@mberndt123
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 Foo.foo refers to in another struct. How can I do that?
Zakarum
@omni-viral
Jul 28 2018 20:35
struct Baz<'a> { foo: Option<Foo<'a>>, bar: Bar }

let mut baz = Baz { foo: None, bar: Bar::new() };
let baz.foo = Some(Foo { foo: &baz.bar });
Not that the last line borrows baz for the entire lifetime of baz
Zakarum
@omni-viral
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
rebo
@rebo
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?
matrixbot
@matrixbot
Jul 28 2018 23:06
bspeice You can wrap foo.bar 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.