Deprecate NoTeamAttribute and CannotDetermineTeams
This commit is contained in:
@@ -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.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user