mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-04 02:24:12 +02:00
derive FromStr
This commit is contained in:
parent
023d2c6f40
commit
68416d6025
2 changed files with 15 additions and 22 deletions
|
|
@ -7,16 +7,26 @@ use crate::demo::packet::datatable::{ClassId, SendTable, SendTableName, ServerCl
|
|||
use crate::demo::parser::ParseBitSkip;
|
||||
use crate::demo::sendprop::{SendProp, SendPropDefinition, SendPropValue};
|
||||
use crate::{MalformedDemoError, Parse, ParseError, ParserState, ReadResult, Result, Stream};
|
||||
use parse_display::Display;
|
||||
use parse_display::{Display, FromStr};
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::hint::unreachable_unchecked;
|
||||
use std::num::ParseIntError;
|
||||
use std::rc::Rc;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(
|
||||
Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Display, Ord, PartialOrd,
|
||||
Debug,
|
||||
Copy,
|
||||
Clone,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Display,
|
||||
Ord,
|
||||
PartialOrd,
|
||||
FromStr,
|
||||
)]
|
||||
pub struct EntityId(u32);
|
||||
|
||||
|
|
@ -26,14 +36,6 @@ impl From<u32> for EntityId {
|
|||
}
|
||||
}
|
||||
|
||||
impl FromStr for EntityId {
|
||||
type Err = ParseIntError;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
u32::from_str(s).map(EntityId::from)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(BitRead, Clone, Copy, Debug, PartialEq, Eq, Serialize_repr, Deserialize_repr)]
|
||||
#[discriminant_bits = 2]
|
||||
#[repr(u8)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue