following some clippy recommendations

This commit is contained in:
2020-10-15 23:54:23 +01:00
parent 11c9430ccf
commit 1d7e3f0704
5 changed files with 29 additions and 32 deletions

View File

@@ -6,7 +6,7 @@ use std::str::FromStr;
use std::collections::HashMap;
use std::borrow::BorrowMut;
use std::fmt;
use std::fmt::Display;
use std::fmt::{Display, Formatter};
/// in very early versions of Bitsy, room tiles were defined as single alphanumeric characters -
/// so there was a maximum of 36 unique tiles. later versions are comma-separated.
@@ -25,12 +25,14 @@ impl RoomFormat {
_ => Err(InvalidRoomFormat),
}
}
}
fn to_string(&self) -> String {
match &self {
impl Display for RoomFormat {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", match &self {
RoomFormat::Contiguous => "0",
RoomFormat::CommaSeparated => "1",
}.to_string()
})
}
}
@@ -826,22 +828,17 @@ impl Game {
}
fn font_line(&self) -> String {
if self.font == Font::AsciiSmall {
"".to_string()
} else {
if self.font == Font::Custom {
format!("\n\nDEFAULT_FONT {}", self.custom_font.as_ref().unwrap())
} else {
format!("\n\nDEFAULT_FONT {}", self.font.to_string().unwrap())
}
match self.font {
Font::AsciiSmall => "".to_string(),
Font::Custom => format!("\n\nDEFAULT_FONT {}", self.custom_font.as_ref().unwrap()),
_ => format!("\n\nDEFAULT_FONT {}", self.font.to_string().unwrap()),
}
}
fn text_direction_line(&self) -> &str {
if self.text_direction == TextDirection::RightToLeft {
"\n\nTEXT_DIRECTION RTL"
} else {
""
match self.text_direction {
TextDirection::RightToLeft => "\n\nTEXT_DIRECTION RTL",
_ => "",
}
}