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