formatted namings in user.rs

This commit is contained in:
JustTestingV 2023-09-15 19:31:36 +03:00
parent bb2e4eecf8
commit e5481035a7
4 changed files with 10 additions and 10 deletions

View File

@ -302,7 +302,7 @@ impl Player {
player_id,
connections: AnonTable::new(),
my_rooms: HashMap::new(),
banned_from: HashSet::from([RoomId::from("empty").unwrap()]),
banned_from: HashSet::from([RoomId::from("Empty").unwrap()]),
rx,
handle,
rooms,

View File

@ -669,8 +669,8 @@ async fn produce_on_join_cmd_messages(
}
.write_async(writer)
.await?;
let prefixed_members: Vec<PrefixedNick> = room_info.members.iter().map(|member| PrefixedNick::fromPlayerId(member.clone())).collect();
let non_empty_members: NonEmpty<PrefixedNick> = NonEmpty::from_vec(prefixed_members).unwrap_or(nonempty![PrefixedNick::fromStr(user.nickname.clone())]);
let prefixed_members: Vec<PrefixedNick> = room_info.members.iter().map(|member| PrefixedNick::from_player_id(member.clone())).collect();
let non_empty_members: NonEmpty<PrefixedNick> = NonEmpty::from_vec(prefixed_members).unwrap_or(nonempty![PrefixedNick::from_str(user.nickname.clone())]);
ServerMessage {
tags: vec![],

View File

@ -4,13 +4,13 @@ use crate::core::player::PlayerId;
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Prefix {
empty,
Empty,
}
impl fmt::Display for Prefix {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Prefix::empty => write!(f, ""),
Prefix::Empty => write!(f, ""),
}
}
}
@ -22,11 +22,11 @@ pub struct PrefixedNick {
}
impl PrefixedNick {
pub fn fromStr(nick: Str) -> PrefixedNick {
PrefixedNick { prefix: Prefix::empty, nick }
pub fn from_str(nick: Str) -> PrefixedNick {
PrefixedNick { prefix: Prefix::Empty, nick }
}
pub fn fromPlayerId(id: PlayerId) -> PrefixedNick {
PrefixedNick { prefix: Prefix::empty, nick: id.into_inner() }
pub fn from_player_id(id: PlayerId) -> PrefixedNick {
PrefixedNick { prefix: Prefix::Empty, nick: id.into_inner() }
}
}

View File

@ -21,7 +21,7 @@ impl<V> AnonTable<V> {
pub fn insert(&mut self, value: V) -> Key {
let id = self.next;
self.next += 1;
self.inner.insert(id, value); // should be always empty
self.inner.insert(id, value); // should be always Empty
Key(id)
}