From b31bc2e4dfeffcfe0667b64d64df976920f83d16 Mon Sep 17 00:00:00 2001 From: Juggle Tux Date: Thu, 15 Mar 2018 18:10:34 +0100 Subject: [PATCH] use `extern crate num` only once to make my answer from [here](https://users.rust-lang.org/t/how-can-i-improve-my-too-object-oriented-code/16180/2?u=juggle-tux) working --- src/sim_elements.rs | 6 ++---- src/simulation.rs | 6 ++---- src/vector.rs | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/sim_elements.rs b/src/sim_elements.rs index 41d2e64..f20a56c 100644 --- a/src/sim_elements.rs +++ b/src/sim_elements.rs @@ -1,7 +1,5 @@ -extern crate num; - use vector::Vector2; -use num::{Float,Integer,NumCast}; +use num::{self,Float,Integer,NumCast}; use simulation::SimData; pub trait Simulable where T: Float, U: Integer { @@ -40,4 +38,4 @@ impl Simulable for Planet where T: Float, U: Integer + NumCast { my_data.vel = my_data.vel + inst_accel * dt; my_data.pos = my_data.pos + my_data.vel * dt; } -} \ No newline at end of file +} diff --git a/src/simulation.rs b/src/simulation.rs index b48421e..92c021c 100644 --- a/src/simulation.rs +++ b/src/simulation.rs @@ -1,7 +1,5 @@ -extern crate num; - use std::fmt; -use num::{Float,Integer,NumCast}; +use num::{self,Float,Integer,NumCast}; use vector::Vector2; use sim_elements::Simulable; @@ -72,4 +70,4 @@ impl fmt::Display for Simulation where T: Float + fmt::Display, U: Int } Ok(()) } -} \ No newline at end of file +} diff --git a/src/vector.rs b/src/vector.rs index ff61b0e..03037da 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -1,7 +1,5 @@ -extern crate num; - use std::fmt; -use num::Float; +use num::{self,Float}; use std::ops::{Add,Sub,Mul,Div}; #[derive(Debug, Eq, PartialEq, Clone, Copy)] @@ -106,4 +104,4 @@ mod tests{ fn norm_test() { assert_eq!(Vector2:: { x: 4., y: -3.}.norm(), 5_f64); } -} \ No newline at end of file +}