autofmt
This commit is contained in:
@@ -78,7 +78,6 @@ async fn websocket(socket: WebSocket, state: Arc<AppState>) {
|
||||
let mut rx = state.tx.subscribe();
|
||||
let _ = state.tx.send(format!("{username} joined the lobby!"));
|
||||
|
||||
|
||||
// Read messages broadcast through the server, write them to this socket.
|
||||
// If any error is returned, break the loop to terminate the task. We're
|
||||
// not dealing with them right now.
|
||||
@@ -111,18 +110,18 @@ async fn websocket(socket: WebSocket, state: Arc<AppState>) {
|
||||
}
|
||||
|
||||
/// Sets the requested username into buffer `name_out` if it is currently unused in the lobby.
|
||||
///
|
||||
///
|
||||
/// Check for presence of `name` in `state.user_set`. If taken, the `name_out` out-parameter
|
||||
/// is left unchanged (which should be empty, signaling to the caller that the name is
|
||||
/// unavailable).
|
||||
///
|
||||
/// If the name is available, it is added to `state.user_set` (thus making it unavailable
|
||||
/// going forward) and written into the `name_out` buffer for use by the caller (non-empty
|
||||
/// values signal that the name has been accepted for use).
|
||||
/// values signal that the name has been accepted for use).
|
||||
fn check_username(state: &AppState, name_out: &mut String, name: &str) {
|
||||
// TODO: Return a Result instead of using out-parameters. This isn't C,
|
||||
// we can do better.
|
||||
let mut user_set= state.user_set.lock().unwrap();
|
||||
let mut user_set = state.user_set.lock().unwrap();
|
||||
if !user_set.contains(name) {
|
||||
user_set.insert(name.to_owned());
|
||||
name_out.push_str(name);
|
||||
|
||||
Reference in New Issue
Block a user