fn exit_rooms(&mut self, id: usize) {
        self.rooms
            .iter_mut()
            .filter_map(|(name, sessions)| {
                if sessions.remove(&id) {
                    Some(name.to_owned())
                } else {
                    None
                }
            })
            .collect::<Vec<String>>()
            .into_iter()
            // send message to other users
            .for_each(|room| self.send_message(&room, "Someone disconnected", 0))
    }
// remove id from all rooms and send message to other users.
remove id from all rooms and send message to other users.
remove id from all rooms and send message to other users .
fn exit_rooms(&mut self, id: usize) {
        self.rooms
            .iter_mut()
            .filter_map(|(name, sessions)| {
                if sessions.remove(&id) {
                    Some(name.to_owned())
                } else {
                    None
                }
            })
            .collect::<Vec<String>>()
            .into_iter()
            // send message to other users
            .for_each(|room| self.send_message(&room, "Someone disconnected", 0))
    }
fn exit_rooms ( & mut self , id : usize ) { self . rooms . iter_mut ( ) . filter_map ( | ( name , sessions ) | { if sessions . remove ( & id ) { Some ( name . to_owned ( ) ) } else { None } } ) . collect :: < Vec < String > > ( ) . into_iter ( ) // send message to other users . for_each ( | room | self . send_message ( & room , " " , 0 ) ) }
remove id from all rooms and send message to other users.
remove id from all rooms and send message to other users .
&mut self
id
usize