pub fn player_get_item(state: &mut State, item: Item) -> NRResult<ParsingResult> {
    let current_room_id = state.current_room;
    let current_room = state
        .rooms
        .iter_mut()
        .find(|room| room.id == current_room_id)
        .unwrap();

    match current_room.stash.remove_item(item) {
        Ok(item) => {
            state.player.inventory.add_item(item.clone());
            let message = format!("\nYou now have a {}\n", item.name);
            Ok(ParsingResult::NewItem(message))
        }
        Err(_) => Err(NoItem.into()),
    }
}
/// This function is used when the player issues a command
/// to take an item.
///
/// If the Item is not found in the room, then a ParsingError is returned
/// with a message indicating that the item was not found.
/// Otherwise, the item is removed from the room and added to the player's
/// inventory and a ParsingResult is returned with a message indicating that
/// the item was taken.
This function is used when the player issues a command
to take an item.

If the Item is not found in the room, then a ParsingError is returned
with a message indicating that the item was not found.
Otherwise, the item is removed from the room and added to the player's
inventory and a ParsingResult is returned with a message indicating that
the item was taken.
This function is used when the player issues a command to take an item . If the Item is not found in the room then a ParsingError is returned with a message indicating that the item was not found . Otherwise the item is removed from the room and added to the player ' s inventory and a ParsingResult is returned with a message indicating that the item was taken .
pub fn player_get_item(state: &mut State, item: Item) -> NRResult<ParsingResult> {
    let current_room_id = state.current_room;
    let current_room = state
        .rooms
        .iter_mut()
        .find(|room| room.id == current_room_id)
        .unwrap();
    match current_room.stash.remove_item(item) {
        Ok(item) => {
            state.player.inventory.add_item(item.clone());
            let message = format!("\nYou now have a {}\n", item.name);
            Ok(ParsingResult::NewItem(message))
        }
        Err(_) => Err(NoItem.into()),
    }
}
pub fn player_get_item ( state : & mut State , item : Item ) -> NRResult < ParsingResult > { let current_room_id = state . current_room ; let current_room = state . rooms . iter_mut ( ) . find ( | room | room . id == current_room_id ) . unwrap ( ) ; match current_room . stash . remove_item ( item ) { Ok ( item ) => { state . player . inventory . add_item ( item . clone ( ) ) ; let message = format ! ( " \n \n " item name ) ; Ok ( ParsingResult :: NewItem ( message ) ) } Err ( _ ) => Err ( NoItem . into ( ) ) , } }
This function is used when the player issues a command
to take an item.
This function is used when the player issues a command to take an item .
state
&mut State
item
Item
state
&mut State
item
Item