These are chat archives for rust-lang/rust

10th
Feb 2017
Peter Atashian
@retep998
Feb 10 2017 00:05 UTC
In Java the behavior is omnipresent, in Rust it is opt-in
mhsjlw
@mhsjlw
Feb 10 2017 01:49 UTC
-1 as f64 ?
non-scalar cast: {integer} as f64
I just need to call a function that takes an f64 :P
mhsjlw
@mhsjlw
Feb 10 2017 01:57 UTC
I fixed it
-1f64
hmm
what's the difference?
ah, one is casting one is setting the type? idk
return self.lerp(0f64, self.lerp(w, self.lerp(u, self.grad(self.permutations[b as usize], x, z, 0f64), self.grad(self.permutations[pz as usize], x - 1.0 as f64, z, 0f64)), self.lerp(u, self.grad(self.permutations[a as usize], x, z - 1.0 as f64, 0f64), self.grad(self.permutations[px as usize], x - 1.0 as f64, z - 1.0 as f64, 0f64))), self.lerp(w, self.lerp(u, self.grad(self.permutations[(b + 1) as usize], x, z, -1f64), self.grad(self.permutations[(pz + 1) as usize], x - 1.0 as f64, z, -1f64)), self.lerp(u, self.grad(self.permutations[(a + 1) as usize], x, z - 1.0 as f64, -1f64), self.grad(self.permutations[(px + 1) as usize], x - 1.0 as f64, z - 1.0 as f64, -1f64))));
very clean, concise code
thanks
lol
mhsjlw
@mhsjlw
Feb 10 2017 02:06 UTC
say you'd do something like private PerlinNoise[] algs; in java. then this.algs = new PerlinNoise[algs];
I would want to do the same in Rust by creating a vector of boxes that hold pointers to that perlin noise object ?
how should I do this ? hmm
I did
fn new(count: i32) -> OctaveNoise {
    let mut algs = vec![];

    for i in 0..count {
      algs.push(PerlinNoise::new());
    }

    OctaveNoise {
      algs: algs,
      count: count
    }
  }
let me know if that's wrong/another way
mhsjlw
@mhsjlw
Feb 10 2017 02:12 UTC
Also, what is the Rust equivalent of interfaces?
I'm trying to port some Java code if you haven't noticed :P
just some noise stuff
Peter Atashian
@retep998
Feb 10 2017 02:29 UTC
@mhsjlw Traits are like interfaces
@mhsjlw You might be interested in (0..count).map(|_| PerlinNoise::new()).collect()
alternatively iter::repeat(PerlinNoise::new()).take(count).collect()
@mhsjlw Also do consider using IRC, it is much more active than gitter
Jonas Platte
@jplatte
Feb 10 2017 07:23 UTC
@mhsjlw Instead of 0f64 you can simply write 0.0 (I think 0. and .0 also work here, but I wouldn't personally ever use those shorter forms)
mhsjlw
@mhsjlw
Feb 10 2017 11:05 UTC
@retep998 yeah, I use IRC sometimes instead. I just need to figure out how to make a Noise trait that Perkin and Octave can implement so that my combined noise can accept any of those 2 noises
How would I do this?
No, wait I think I remember
I'll give it a try
mhsjlw
@mhsjlw
Feb 10 2017 11:17 UTC
yup
Alexey
@KalitaAlexey
Feb 10 2017 14:42 UTC
Hello everybody.
Hello users of vscode-rust (RustyCode).
I have opened the PR introducing the documentation about the extension.
Please review it and write what is missing.
KalitaAlexey/vscode-rust#68