PrefixedNick creation raw, not Result

This commit is contained in:
JustTestingV 2023-09-15 19:17:19 +03:00
parent eb123da0e9
commit 1617f428e4
2 changed files with 6 additions and 6 deletions

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()).unwrap()).collect();
let non_empty_members: NonEmpty<PrefixedNick> = NonEmpty::from_vec(prefixed_members).unwrap_or(nonempty![PrefixedNick::fromStr(user.nickname.clone()).unwrap()]);
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())]);
ServerMessage {
tags: vec![],

View File

@ -20,11 +20,11 @@ pub struct PrefixedNick {
pub nick: Str,
}
impl PrefixedNick {
pub fn fromStr(nick: Str) -> Result<PrefixedNick> {
Ok(PrefixedNick { prefix: Prefix::empty, nick } )
pub fn fromStr(nick: Str) -> PrefixedNick {
PrefixedNick { prefix: Prefix::empty, nick }
}
pub fn fromPlayerId(id: PlayerId) -> Result<PrefixedNick> {
Ok(PrefixedNick { prefix: Prefix::empty, nick: id.into_inner() } )
pub fn fromPlayerId(id: PlayerId) -> PrefixedNick {
PrefixedNick { prefix: Prefix::empty, nick: id.into_inner() }
}
}