Skip to content

Commit

Permalink
Use "write!()" and "writeln!()" instead of "write_fmt()"
Browse files Browse the repository at this point in the history
  • Loading branch information
JDDev0 committed Nov 27, 2024
1 parent ce631a6 commit acf8e27
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/game/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,11 +630,11 @@ impl LevelPack {
pub fn save_editor_level_pack_to_path(&self, path: impl Into<String>) -> Result<(), Box<dyn Error>> {
let mut file = File::create(path.into())?;

file.write_fmt(format_args!("Levels: {}\n", self.levels.len()))?;
writeln!(file, "Levels: {}", self.levels.len())?;

for level in self.levels.iter().
map(|level| level.level()) {
file.write_fmt(format_args!("\n{}", level.to_str()))?;
write!(file, "\n{}", level.to_str())?;
}
file.flush()?;

Expand All @@ -648,15 +648,15 @@ impl LevelPack {

let mut file = File::create(save_game_file)?;

file.write_fmt(format_args!("{}\n", self.min_level_not_completed))?;
writeln!(file, "{}", self.min_level_not_completed)?;

for level in self.levels.iter().
take(self.min_level_not_completed) {
file.write_fmt(format_args!(
"ms{},{}\n",
writeln!(
file, "ms{},{}",
level.best_time.map_or(-1, |best_time| best_time as i64),
level.best_moves.map_or(-1, |best_moves| best_moves as i32)
))?;
)?;
}
file.flush()?;

Expand Down

0 comments on commit acf8e27

Please sign in to comment.