pub fn from_file<P: AsRef<Path>>(file_name: P) -> Result<GameState, String> {
        let mut file = match File::open(file_name) {
            Ok(file) => file,
            Err(_) => return Err("File could not be read".to_string()),
        };

        let mut contents = String::new();
        if file.read_to_string(&mut contents).is_err() {
            return Err("File contents could not be read".to_string())
        }

        contents.parse()
    }
/// Parses the contents of a file into a GameState.
///
/// This is equivalent to reading the contents of the file as `&str` and using that as input
/// for `GameState::from_str`
// TODO consider borrowing the file name: `file_name: &P` it doesn't really need to be consumed here, right?
Parses the contents of a file into a GameState.
Parses the contents of a file into a GameState .
pub fn from_file<P: AsRef<Path>>(file_name: P) -> Result<GameState, String> {
        let mut file = match File::open(file_name) {
            Ok(file) => file,
            Err(_) => return Err("File could not be read".to_string()),
        };
        let mut contents = String::new();
        if file.read_to_string(&mut contents).is_err() {
            return Err("File contents could not be read".to_string())
        }
        contents.parse()
    }
pub fn from_file < P : AsRef < Path > > ( file_name : P ) -> Result < GameState , String > { let mut file = match File :: open ( file_name ) { Ok ( file ) => file , Err ( _ ) => return Err ( " " . to_string ( ) ) , } ; let mut contents = String :: new ( ) ; if file . read_to_string ( & mut contents ) . is_err ( ) { return Err ( " " . to_string ( ) ) } contents . parse ( ) }
Parses the contents of a file into a GameState.
Parses the contents of a file into a GameState .
file_name
P
file_name
P