more inlining

This commit is contained in:
Max Bradbury 2020-06-23 20:35:12 +01:00
parent 0889710bdb
commit 58ffb92e52
1 changed files with 4 additions and 0 deletions

View File

@ -36,6 +36,7 @@ pub enum RoomType {Room, Set}
pub struct InvalidRoomType; pub struct InvalidRoomType;
impl RoomType { impl RoomType {
#[inline]
fn from(string: &str) -> Result<RoomType, InvalidRoomType> { fn from(string: &str) -> Result<RoomType, InvalidRoomType> {
match string { match string {
"ROOM" => Ok(RoomType::Room), "ROOM" => Ok(RoomType::Room),
@ -46,6 +47,7 @@ impl RoomType {
} }
impl ToString for RoomType { impl ToString for RoomType {
#[inline]
fn to_string(&self) -> String { fn to_string(&self) -> String {
match &self { match &self {
RoomType::Set => "SET", RoomType::Set => "SET",
@ -64,6 +66,7 @@ pub struct Version {
pub struct InvalidVersion; pub struct InvalidVersion;
impl Version { impl Version {
#[inline]
fn from(str: &str) -> Result<Version, InvalidVersion> { fn from(str: &str) -> Result<Version, InvalidVersion> {
let parts: Vec<&str> = str.split(".").collect(); let parts: Vec<&str> = str.split(".").collect();
if parts.len() == 2 { if parts.len() == 2 {
@ -106,6 +109,7 @@ pub struct GameHasNoAvatar;
// todo no tiles? no rooms? no palettes? // todo no tiles? no rooms? no palettes?
impl Game { impl Game {
#[inline]
pub fn from(string: String) -> Result<Game, GameHasNoAvatar> { pub fn from(string: String) -> Result<Game, GameHasNoAvatar> {
let line_endings_crlf = string.contains("\r\n"); let line_endings_crlf = string.contains("\r\n");
let mut string = string; let mut string = string;