These are chat archives for rust-lang/rust

11th
Dec 2017
Thibault Delor
@thibaultdelor
Dec 11 2017 03:06
Hi there, anyone having problem installing rust on mac atm?
I have created an issue there: rust-lang/rust#46649
I am just surprised that no one else seems to have the problem so I am wondering if I am doing something wrong
Ryan
@rnleach
Dec 11 2017 03:21
@thibaultdelor did you copy your home directory from another machine, such as your old mac? It looks like rustup thinks the stable is already installed. It is probably looking as some kind of cached information in your ~/.rustup file.
you might try removing ~/.rustup/update-hashes/stable* and then run rustup update again, or run you might have to run rustup toolchain add stable
Thibault Delor
@thibaultdelor
Dec 11 2017 04:29
@rnleach , that’s a new computer, nothing installed… I am going to try what you say
Actually, I don’t have stable in my hashes
$ ls -al  ~/.rustup/update-hashes/
total 8
drwxr-xr-x  3 delorth  AU\Domain Users  102 11 Dec 13:34 .
drwxr-xr-x  7 delorth  AU\Domain Users  238 11 Dec 13:31 ..
-rw-r--r--  1 delorth  AU\Domain Users   20 11 Dec 13:34 nightly-x86_64-apple-darwin
$ rustup update
info: syncing channel updates for 'nightly-x86_64-apple-darwin’
info: checking for self-updates

  nightly-x86_64-apple-darwin unchanged - rustc 1.24.0-nightly (2d4df9584 2017-12-10)
$ rustup toolchain add stable
info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: update not yet available, sorry! try again later

  stable-x86_64-apple-darwin unchanged - (toolchain not installed)
Sean
@seanr707
Dec 11 2017 14:12
@thibaultdelor Have you tried removing rustup and reinstaling?
mnivoliez
@mnivoliez
Dec 11 2017 20:20
Hi! I got an issue:
for act in &mut self.boids {
  update_actor_position(act, &self.boids, seconds);
  wrap_actor_position(act, self.screen_width as f32, self.screen_height as f32);
}
Obviously, the compiler yell because I try to make a second borrowing after a mutable one. Is there any elegant solution to that?
mnivoliez
@mnivoliez
Dec 11 2017 20:25
I try to get the average distance beetween one boid and every other one
And then I modify his velocity
Denis Lisov
@tanriol
Dec 11 2017 20:31
I'd probably first calculate all distances and then update all positions.
mnivoliez
@mnivoliez
Dec 11 2017 20:34
hum how if i may ask?
Denis Lisov
@tanriol
Dec 11 2017 20:36
In two separate loops :-) as a side effect, the velocity changes will not depend on the order of boids.
mnivoliez
@mnivoliez
Dec 11 2017 20:37
Then I have to enforce vec order
Denis Lisov
@tanriol
Dec 11 2017 20:42
Do you mean between the loops?
mnivoliez
@mnivoliez
Dec 11 2017 20:51
RRRR
not working
   Compiling boids v0.1.0 (file:///home/mnivoliez/workspace/boids)
error[E0382]: use of moved value: `boids`
   --> src/main.rs:115:21
    |
113 |     for traveler in boids {
    |                     ----- value moved here
114 |         let mut avgVec: Vector2 = na::zero();
115 |         for boid in boids {
    |                     ^^^^^ value used here after move
    |
    = note: move occurs because `boids` has type `&mut std::vec::Vec<Actor>`, which does not implement the `Copy` trait

error: aborting due to previous error

error: Could not compile `boids`.

To learn more, run the command again with --verbose.
the method:
fn update_boids_position(boids: &mut Vec<Actor>) {
    let nb_boids = boids.len() as f32;
    let mut avg_velocities: Vec<Vector2> = Vec::new();
    for traveler in boids {
        let mut avgVec: Vector2 = na::zero();
        for boid in boids {
            if traveler != boid {
                avgVec += boid.pos - traveler.pos;
            }
        }
        avgVec /= nb_boids;
        avg_velocities.push(traveler.velocity - avgVec / 100.);
    }
}
I tried to do for boid in &boids but it does complain
Compiling boids v0.1.0 (file:///home/mnivoliez/workspace/boids)
error[E0277]: the trait bound `&&mut std::vec::Vec<Actor>: std::iter::Iterator` is not satisfied
   --> src/main.rs:113:5
    |
113 | /     for traveler in &boids {
114 | |         let mut avgVec: Vector2 = na::zero();
115 | |         for boid in boids {
116 | |             if traveler != boid {
...   |
121 | |         avg_velocities.push(traveler.velocity - avgVec / 100.);
122 | |     }
    | |_____^ `&&mut std::vec::Vec<Actor>` is not an iterator; maybe try calling `.iter()` or a similar method
    |
    = help: the trait `std::iter::Iterator` is not implemented for `&&mut std::vec::Vec<Actor>`
    = note: required by `std::iter::IntoIterator::into_iter`

error: aborting due to previous error

error: Could not compile `boids`.

To learn more, run the command again with --verbose.
gonna drive me mad.
Denis Lisov
@tanriol
Dec 11 2017 20:55
I'd try in &*boids