Started creation of FileData trait.

This commit is contained in:
Jacob VanDomelen 2019-05-27 21:54:54 -07:00
parent 8946a3cfb8
commit c929e6b3a5
3 changed files with 26 additions and 10 deletions

View file

@ -2,8 +2,25 @@ mod state;
use super::tree; use super::tree;
use std::str::FromStr;
use uuid::Uuid; use uuid::Uuid;
impl tree::Tree<Uuid> {
pub fn run_simulation(&self) {
println!("================================");
println!("Running simulation for node: {}", self.val);
println!("With children {} and {}", tree::fmt_node(&self.left), tree::fmt_node(&self.right));
}
}
impl FromStr for tree::Tree<Uuid> {
type Err = tree::ParseTreeError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
}
}
// pub struct Bracket { // pub struct Bracket {
// tree: tree::Tree, // tree: tree::Tree,
// directory: String // directory: String

View file

@ -0,0 +1,3 @@
trait FileData {
}

View file

@ -1,9 +1,9 @@
use std::fmt; use std::fmt;
pub struct Tree<T> { pub struct Tree<T> {
val: T, pub val: T,
left: Option<Box<Tree<T>>>, pub left: Option<Box<Tree<T>>>,
right: Option<Box<Tree<T>>> pub right: Option<Box<Tree<T>>>
} }
pub fn combine_trees<T>(v: T, l: Option<Box<Tree<T>>>, r: Option<Box<Tree<T>>>) -> Tree<T> { pub fn combine_trees<T>(v: T, l: Option<Box<Tree<T>>>, r: Option<Box<Tree<T>>>) -> Tree<T> {
@ -27,17 +27,13 @@ impl<T: fmt::Display> fmt::Display for Tree<T> {
} }
} }
fn fmt_node<T: fmt::Display>(t: &Option<Box<Tree<T>>>) -> String { pub fn fmt_node<T: fmt::Display>(t: &Option<Box<Tree<T>>>) -> String {
match t { match t {
Some(n) => format!("{}", (*n).val), Some(n) => format!("{}", (*n).val),
_ => String::from("_") _ => String::from("_")
} }
} }
impl<T: fmt::Display> Tree<T> { struct ParseTreeError {
pub fn run_simulation(&self) { msg: String
println!("================================");
println!("Running simulation for node: {}", self.val);
println!("With children {} and {}", fmt_node(&self.left), fmt_node(&self.right));
}
} }