derive tweaks

This commit is contained in:
Robin Appelman 2026-11-15 16:24:02 +01:00
commit 1ce783ec11
Signed by: robin
SSH key fingerprint: SHA256:kifqgrqnut7q1YUIrI0AdMNC23qiKAS/T9uGFmIYvbE
12 changed files with 99 additions and 806 deletions

View file

@ -8,6 +8,7 @@ use crate::{Error, Events, IResult, RawEvent, RawEventType, Result, SubjectId};
pub use game::*;
pub use medic::*;
pub use player::*;
use std::borrow::Cow;
use std::net::SocketAddr;
use std::num::NonZeroU32;
use std::str::FromStr;
@ -204,6 +205,12 @@ impl<'a> EventField<'a> for &'a str {
}
}
impl<'a> EventField<'a> for Cow<'a, str> {
fn parse_field(input: &'a str) -> Result<Self> {
Ok(input.into())
}
}
impl<'a, T: EventField<'a>> EventField<'a> for Option<T> {
fn parse_field(input: &'a str) -> Result<Self> {
T::parse_field(input).map(Some)