no need to take ownership of additional game for merge
This commit is contained in:
parent
91883079a3
commit
0763d15b0e
|
@ -12,7 +12,7 @@ fn main() {
|
|||
let mut game_a = Game::from(fs::read_to_string(game_a).unwrap()).unwrap();
|
||||
let game_b = Game::from(fs::read_to_string(game_b).unwrap()).unwrap();
|
||||
|
||||
game_a.merge(game_b);
|
||||
game_a.merge(&game_b);
|
||||
|
||||
fs::write(output, game_a.to_string())
|
||||
.expect("Failed to write output file");
|
||||
|
|
|
@ -314,7 +314,7 @@ impl Game {
|
|||
}
|
||||
|
||||
// return? array of changes made? error/ok?
|
||||
pub fn merge(&mut self, game: Game) {
|
||||
pub fn merge(&mut self, game: &Game) {
|
||||
// ignore title, version, room format, room type, font, text direction
|
||||
|
||||
let mut palette_id_changes: HashMap<String, String> = HashMap::new();
|
||||
|
@ -942,7 +942,7 @@ mod test {
|
|||
fn merge() {
|
||||
// try merging two default games
|
||||
let mut game = crate::mock::game_default();
|
||||
game.merge(crate::mock::game_default());
|
||||
game.merge(&crate::mock::game_default());
|
||||
|
||||
assert_eq!(game.room_ids(), vec!["0".to_string(), "1".to_string()]);
|
||||
assert_eq!(game.tile_ids(), vec!["a".to_string(), "1".to_string()]); // 0 is reserved
|
||||
|
@ -981,7 +981,7 @@ mod test {
|
|||
room.id = room_id.clone();
|
||||
sprite.room_id = Some(room_id.clone());
|
||||
game_b.add_sprite(sprite);
|
||||
game_a.merge(game_b);
|
||||
game_a.merge(&game_b);
|
||||
assert_eq!(game_a.get_sprite_by_id("2".to_string()).unwrap().room_id, Some(room_id));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue