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
|
|
@ -5,7 +5,7 @@ use crate::demo::sendprop::{
|
|||
SendPropDefinition, SendPropDefinitionIndex, SendPropFlag, SendPropName, SendPropType,
|
||||
};
|
||||
use crate::{MalformedDemoError, Parse, ParseError, ParserState, ReadResult, Result, Stream};
|
||||
use parse_display::Display;
|
||||
use parse_display::{Display, FromStr};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::borrow::Borrow;
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
|
@ -13,19 +13,10 @@ use std::fmt;
|
|||
use std::num::ParseIntError;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(BitRead, Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, Display)]
|
||||
#[derive(BitRead, Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, Display, FromStr)]
|
||||
pub struct ClassId(u16);
|
||||
|
||||
impl FromStr for ClassId {
|
||||
type Err = ParseIntError;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
u16::from_str(s).map(|num| ClassId(num))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u16> for ClassId {
|
||||
fn from(int: u16) -> Self {
|
||||
ClassId(int)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue