Deprecate NoTeamAttribute and CannotDetermineTeams

This commit is contained in:
Cutieguwu
2025-04-23 20:33:18 -04:00
parent bfd135df94
commit a5535354a3
3 changed files with 6 additions and 24 deletions

View File

@@ -27,21 +27,3 @@ impl fmt::Display for TeamsError {
}
}
}
#[derive(Debug)]
pub struct NoTeamAttribute;
impl fmt::Display for NoTeamAttribute {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Object has no team definition.")
}
}
#[derive(Debug)]
pub struct CannotDetermineTeams;
impl fmt::Display for CannotDetermineTeams {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Cannot determine teams present.")
}
}

View File

@@ -1,4 +1,4 @@
use crate::{Down, Play, Quarter, TerrainState, error};
use crate::{Down, Play, Quarter, TerrainState};
use serde::Deserialize;
type Offence = Team;
@@ -73,11 +73,11 @@ impl Event {
/// Returns the team for variants which possess this attribute.
/// Errors if `self` has no team attribute.
pub fn team(&self) -> Result<Team, error::NoTeamAttribute> {
pub fn team(&self) -> Option<Team> {
match self {
Self::Kickoff(team) => Ok(team.to_owned()),
Self::Turnover(team) => Ok(team.to_owned()),
_ => Err(error::NoTeamAttribute),
Self::Kickoff(team) => Some(team.to_owned()),
Self::Turnover(team) => Some(team.to_owned()),
_ => None,
}
}

View File

@@ -27,7 +27,7 @@ impl Game {
let mut teams = vec![];
self.events.iter().for_each(|event| {
if let Ok(team) = event.team() {
if let Some(team) = event.team() {
if !ignore.contains(&team) && !teams.contains(&team) {
teams.push(team)
}