summaryrefslogtreecommitdiff
path: root/src/math.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/math.rs')
-rw-r--r--src/math.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/math.rs b/src/math.rs
index 127d4b4..689ee65 100644
--- a/src/math.rs
+++ b/src/math.rs
@@ -1,11 +1,16 @@
extern crate rand;
+use self::rand::distributions::Alphanumeric;
use self::rand::Rng;
+use std::iter::repeat;
-pub fn distance(l0 : (f64, f64, f64), l1 : (f64, f64, f64)) -> f64 {
- (((l1.0-l0.0).powf(2.0) + (l1.1-l0.1).powf(2.0) + (l1.2-l0.2).powf(2.0))).sqrt()
+pub fn distance(l0: (f64, f64, f64), l1: (f64, f64, f64)) -> f64 {
+ ((l1.0 - l0.0).powf(2.0) + (l1.1 - l0.1).powf(2.0) + (l1.2 - l0.2).powf(2.0)).sqrt()
}
pub fn rand_name() -> String {
- rand::thread_rng().gen_ascii_chars().take(8).collect()
+ repeat(())
+ .map(|()| rand::thread_rng().sample(Alphanumeric))
+ .take(8)
+ .collect()
}