1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-04 02:24:12 +02:00

dont clone game event values

This commit is contained in:
Robin Appelman 2019-08-12 13:29:35 +02:00
commit 50f3690e3a
4 changed files with 6086 additions and 4248 deletions

View file

@ -44,16 +44,16 @@ pub enum GameEventValue {
}
pub trait FromGameEventValue: Sized {
fn from_value(value: GameEventValue, name: &str) -> Result<Self>;
fn from_value(value: GameEventValue, name: &'static str) -> Result<Self>;
}
impl FromGameEventValue for String {
fn from_value(value: GameEventValue, name: &str) -> Result<Self> {
fn from_value(value: GameEventValue, name: &'static str) -> Result<Self> {
match value {
GameEventValue::String(val) => Ok(val),
_ => Err(ParseError::InvalidGameEvent {
expected_type: GameEventValueType::String,
name: name.to_string(),
name,
value,
}),
}
@ -61,12 +61,12 @@ impl FromGameEventValue for String {
}
impl FromGameEventValue for f32 {
fn from_value(value: GameEventValue, name: &str) -> Result<Self> {
fn from_value(value: GameEventValue, name: &'static str) -> Result<Self> {
match value {
GameEventValue::Float(val) => Ok(val),
_ => Err(ParseError::InvalidGameEvent {
expected_type: GameEventValueType::Float,
name: name.to_string(),
name,
value,
}),
}
@ -74,12 +74,12 @@ impl FromGameEventValue for f32 {
}
impl FromGameEventValue for u32 {
fn from_value(value: GameEventValue, name: &str) -> Result<Self> {
fn from_value(value: GameEventValue, name: &'static str) -> Result<Self> {
match value {
GameEventValue::Long(val) => Ok(val),
_ => Err(ParseError::InvalidGameEvent {
expected_type: GameEventValueType::Long,
name: name.to_string(),
name,
value,
}),
}
@ -87,12 +87,12 @@ impl FromGameEventValue for u32 {
}
impl FromGameEventValue for u16 {
fn from_value(value: GameEventValue, name: &str) -> Result<Self> {
fn from_value(value: GameEventValue, name: &'static str) -> Result<Self> {
match value {
GameEventValue::Short(val) => Ok(val),
_ => Err(ParseError::InvalidGameEvent {
expected_type: GameEventValueType::Short,
name: name.to_string(),
name,
value,
}),
}
@ -100,12 +100,12 @@ impl FromGameEventValue for u16 {
}
impl FromGameEventValue for u8 {
fn from_value(value: GameEventValue, name: &str) -> Result<Self> {
fn from_value(value: GameEventValue, name: &'static str) -> Result<Self> {
match value {
GameEventValue::Byte(val) => Ok(val),
_ => Err(ParseError::InvalidGameEvent {
expected_type: GameEventValueType::Byte,
name: name.to_string(),
name,
value,
}),
}
@ -113,12 +113,12 @@ impl FromGameEventValue for u8 {
}
impl FromGameEventValue for bool {
fn from_value(value: GameEventValue, name: &str) -> Result<Self> {
fn from_value(value: GameEventValue, name: &'static str) -> Result<Self> {
match value {
GameEventValue::Boolean(val) => Ok(val),
_ => Err(ParseError::InvalidGameEvent {
expected_type: GameEventValueType::Boolean,
name: name.to_string(),
name,
value,
}),
}
@ -126,12 +126,12 @@ impl FromGameEventValue for bool {
}
impl FromGameEventValue for () {
fn from_value(value: GameEventValue, name: &str) -> Result<Self> {
fn from_value(value: GameEventValue, name: &'static str) -> Result<Self> {
match value {
GameEventValue::Local => Ok(()),
_ => Err(ParseError::InvalidGameEvent {
expected_type: GameEventValueType::Local,
name: name.to_string(),
name,
value,
}),
}