From 0004fa2acf33ca6e198d87d2046e972a5c49f2a8 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Fri, 2 Oct 2015 18:35:13 +0200 Subject: [PATCH] fixing stuff again --- src/action.rs | 5 +---- src/block.rs | 14 ++++++++++---- src/main.rs | 1 + src/util.rs | 4 ++++ 4 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 src/util.rs diff --git a/src/action.rs b/src/action.rs index 8a1adbb..8ce72c4 100644 --- a/src/action.rs +++ b/src/action.rs @@ -1,7 +1,4 @@ -pub struct Point { - pub x: i32, - pub y: i32 -} +use util::Point; pub struct Action { pub source: Point, diff --git a/src/block.rs b/src/block.rs index 5f03f95..59ef69a 100644 --- a/src/block.rs +++ b/src/block.rs @@ -1,12 +1,16 @@ use action::Action; use std::vec; +fn make_connections() -> Vec { + vec![0 as f64;9] +} + trait Block { fn get_connections(&self) -> &Vec; fn get_value(&self) -> &f64; fn get_name(&self) -> &'static str; - fn compute(&self) -> Vec; - fn clean(&self); + fn compute(&mut self) -> Vec; + fn clean(&mut self); } struct NeuronBlock { @@ -25,8 +29,10 @@ impl Block for NeuronBlock { fn get_name(&self) -> &'static str { "Neuron" } - fn compute(&self) -> Vec { + fn compute(&mut self) -> Vec { Vec::new() } - fn clean(&self) { } + fn clean(&mut self) { + self.current_value = self.new_value + } } diff --git a/src/main.rs b/src/main.rs index e7ca828..e6c9519 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +mod util; mod action; mod block; diff --git a/src/util.rs b/src/util.rs new file mode 100644 index 0000000..30ba658 --- /dev/null +++ b/src/util.rs @@ -0,0 +1,4 @@ +pub struct Point { + pub x: i32, + pub y: i32 +}