These are chat archives for rust-lang/rust

15th
Dec 2016
salpalvv
@salpalvv
Dec 15 2016 03:07
Hey, I'm working on a coding challenge and I am getting a strange error on travis when i am building against stable and beta. Nightly runs fine. https://travis-ci.org/salpalvv/advent Is there a reason that stable or beta is having an issue finding with the private enum?
salpalvv
@salpalvv
Dec 15 2016 03:19
Is this a bug or is there just a something in nightly that allows the enum to be in scope?
xialvjun
@xialvjun
Dec 15 2016 04:49
impl CircleBuilder {
    fn new() -> CircleBuilder {
        CircleBuilder { x: 0.0, y: 0.0, radius: 1.0, }
    }
    fn x(&mut self, coordinate: f64) -> &mut CircleBuilder {
        self.x = coordinate;
        self
    }
}

fn main() {
    let c = CircleBuilder::new().x(1.0));
}
Why let c = CircleBuilder::new().x(1.0)); is OK? The x take a mut ref, but CircleBuilder::new() didn't produce a mut one.

Eh...

let mut a = vec![1,2,30];

Well, we use mut just at the varible binding, not at where the object produced. &mut self just like let mut a =

Aleksey Kladov
@matklad
Dec 15 2016 05:14
@matanelevi looks like the other end has send less then answer_encoded bytes. I'd suggest to stick println! before reads and writes to make sure you receive the data you have send.
@salpalvv I think this is because this rfc is being implemented https://github.com/rust-lang/rfcs/blob/master/text/1560-name-resolution.md
Aleksey Kladov
@matklad
Dec 15 2016 05:19
One of the features of RFC is to allow use super::* to import private as well public names.
Previously in tests you have to import public stuff via super::* and private stuff via explicitly naming each item super::{foo, bar, baz}.
Sebastian Blei
@iamsebastian
Dec 15 2016 10:23
Anybody could help with this play-pen? I'm still struggling around and don't get the error ... Compiler explanation does not help: https://is.gd/RsobuO
Sebastian Blei
@iamsebastian
Dec 15 2016 10:27
Argh!
Thanks a buck, @matklad
Sebastian Blei
@iamsebastian
Dec 15 2016 11:14
I run into issues when I try to manipulate Vectors inside self-fns. Could anybody provide a solution for this simplified problem: http://play.integer32.com/?gist=2201954ffe3ea0907ccf91c4165ff454&version=stable
Aleksey Kladov
@matklad
Dec 15 2016 11:15
Looks like the len is missing a &: fn len(&self) -> usize
As a rule of thumb, start with &self argument and change it to self or &mut self if appropriate.
Sebastian Blei
@iamsebastian
Dec 15 2016 11:17
Thanks. I think, I need to split up my fn, where I check for length and also extend the vector, into two fns. I will give it a try.
Aleksey Kladov
@matklad
Dec 15 2016 11:19
Hm, the playground you've linked is fixed by just adding a single &.
Sebastian Blei
@iamsebastian
Dec 15 2016 11:19
Yeah. I've simplified my Impl. So this is enough. But not at my local one. I will write a larger pen.
Sebastian Blei
@iamsebastian
Dec 15 2016 11:34
Ok, splitting up the fn into find_x(&self) and add_x(&mut self) fns did the trick. Thanks again, @matklad
Aleksey Kladov
@matklad
Dec 15 2016 11:46
@iamsebastian looking at your code, I think you might hit this problem soon: http://play.integer32.com/?gist=3091ba6d67571d2bb0e4197c02f24b40&version=stable :)
Sebastian Blei
@iamsebastian
Dec 15 2016 11:48
But I do not use a Counter. I always check for the length of the data Vector.
Aleksey Kladov
@matklad
Dec 15 2016 11:48
Yep, your case works, because you have &self and &mut self functions,
but when you try to use two &mut self functions, you'll have to split your structure in disjoint parts.
Sebastian Blei
@iamsebastian
Dec 15 2016 11:49
Yeah. Maybe this will follow. :X
It's like always, if you do Backend & Frontend in a project: Will you prepare the data for a "special pivot table" within the backend or the frontend ... And it's always getting hours, constructing "the data right" for showing up a pivot table in HTML.
Because the customer not only wants to iterate the data within the template, no ... He always wants to group the data anywhere between ... And then you start to struggle.
"Why does this takes so long. You only need to show the data."
"Erm. Yo."
Pavel Meledin
@btbvoy
Dec 15 2016 15:24
@matklad Hi, any chance that JetBrains will invest into intellij-rust plugin and will turn it into full-fledged Rust IDEA like they did with Gogland for Go ?
Aleksey Kladov
@matklad
Dec 15 2016 16:30
@btbvoy I work at JetBrains full time on the plugin :) The amount of resources invested in the particular language obviously depends on the language popularity. Rust is not widely used yet, but I expect this to change.
Pavel Meledin
@btbvoy
Dec 15 2016 16:33
@matklad got it! Thanks for update. Hope it will happen soon :-)