add mut to the pool O_o
This commit is contained in:
parent
0a63ab5b53
commit
9d0b96b4d7
11
src/main.rs
11
src/main.rs
@ -21,17 +21,18 @@ mod robot;
|
|||||||
mod world;
|
mod world;
|
||||||
|
|
||||||
/// Parse the config file, generate the world and robot pool.
|
/// Parse the config file, generate the world and robot pool.
|
||||||
fn parse_config(raw_conf: String, pool: &Vec<robot::Robot>) -> Result<world::World, &'static str> {
|
fn parse_config(conf: String, pool: &mut Vec<robot::Robot>) -> Result<world::World, &'static str> {
|
||||||
let mut lines = raw_conf.lines();
|
let mut lines = conf.lines();
|
||||||
// The first line of the config file should be the World.
|
// The first line of the config file should be the World.
|
||||||
let raw_line: &str = match lines.next() {
|
let raw_line: &str = match lines.next() {
|
||||||
None => return Err("Could not read the first line of the config file !"),
|
None => return Err("Could not read the first line of the config file !"),
|
||||||
Some(raw) => raw,
|
Some(raw) => raw,
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
let raw_token = raw_line.split_whitespace();
|
let raw_token = raw_line.split_whitespace();
|
||||||
let token1 = raw_token.next();
|
let token1 = raw_token.next();
|
||||||
let token2 = raw_token.next();
|
let token2 = raw_token.next();
|
||||||
// Need to check if the robots fit in the World.
|
*/
|
||||||
Ok(world::World { x: 5, y: 5 })
|
Ok(world::World { x: 5, y: 5 })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,8 +58,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
let raw_conf = open_file(matches.value_of("file").unwrap_or("two_robots.txt"))?;
|
let raw_conf = open_file(matches.value_of("file").unwrap_or("two_robots.txt"))?;
|
||||||
|
|
||||||
let robot_pool: Vec<robot::Robot> = Vec::new();
|
let mut robot_pool: Vec<robot::Robot> = Vec::new();
|
||||||
let world: world::World = parse_config(raw_conf, &robot_pool)?;
|
let world: world::World = parse_config(raw_conf, &mut robot_pool)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user