mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-11-30 12:50:49 +01:00
add as_str to Weapon
This commit is contained in:
parent
371fe4079d
commit
74540420f4
1 changed files with 10 additions and 4 deletions
|
|
@ -186,14 +186,20 @@ pub enum Weapon {
|
||||||
Other(String),
|
Other(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Weapon {
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
match self {
|
||||||
|
Weapon::Other(other) => other.as_str(),
|
||||||
|
_ => self.as_ref(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Serialize for Weapon {
|
impl Serialize for Weapon {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: serde::Serializer,
|
S: serde::Serializer,
|
||||||
{
|
{
|
||||||
match self {
|
self.as_str().serialize(serializer)
|
||||||
Weapon::Other(other) => other.serialize(serializer),
|
|
||||||
_ => self.as_ref().serialize(serializer),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue