default team

This commit is contained in:
Robin Appelman 2021-12-29 13:34:45 +01:00
commit b638105566

View file

@ -17,6 +17,12 @@ pub enum Team {
Spectator, Spectator,
} }
impl Default for Team {
fn default() -> Self {
Team::Spectator
}
}
impl Team { impl Team {
pub fn as_str(self) -> &'static str { pub fn as_str(self) -> &'static str {
match self { match self {
@ -270,7 +276,7 @@ impl TryFrom<&RawSubject<'_>> for SubjectData {
user_id: user_id.parse().map_err(|_| SubjectError::InvalidUserId)?, user_id: user_id.parse().map_err(|_| SubjectError::InvalidUserId)?,
steam_id: SteamID::from_steam3(steam_id) steam_id: SteamID::from_steam3(steam_id)
.map_err(|_| SubjectError::InvalidSteamId)?, .map_err(|_| SubjectError::InvalidSteamId)?,
team: team.parse().map_err(|_| SubjectError::InvalidTeam)?, team: team.parse().unwrap_or_default(),
} }
} }
RawSubject::Team(team) => SubjectData::Team(*team), RawSubject::Team(team) => SubjectData::Team(*team),