lf2_parse/
weapon_strength_index.rs1use std::{
2 fmt::{self, Display},
3 num::ParseIntError,
4 ops::{Deref, DerefMut},
5 str::FromStr,
6};
7
8#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
10pub struct WeaponStrengthIndex(pub usize);
11
12impl Deref for WeaponStrengthIndex {
13 type Target = usize;
14
15 fn deref(&self) -> &Self::Target {
16 &self.0
17 }
18}
19
20impl DerefMut for WeaponStrengthIndex {
21 fn deref_mut(&mut self) -> &mut Self::Target {
22 &mut self.0
23 }
24}
25
26impl Display for WeaponStrengthIndex {
27 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
28 write!(f, "{}", self.0)
29 }
30}
31
32impl FromStr for WeaponStrengthIndex {
33 type Err = ParseIntError;
34
35 fn from_str(s: &str) -> Result<WeaponStrengthIndex, ParseIntError> {
36 s.parse::<usize>().map(Self)
37 }
38}