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) .write_async(writer)
.await?; .await?;
let prefixed_members: Vec<PrefixedNick> = room_info.members.iter().map(|member| PrefixedNick::fromPlayerId(member.clone()).unwrap()).collect(); 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()).unwrap()]); let non_empty_members: NonEmpty<PrefixedNick> = NonEmpty::from_vec(prefixed_members).unwrap_or(nonempty![PrefixedNick::fromStr(user.nickname.clone())]);
ServerMessage { ServerMessage {
tags: vec![], tags: vec![],

View File

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