diff options
| author | troido <troido@protonmail.com> | 2020-09-24 22:18:30 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-09-24 22:18:30 +0200 |
| commit | 9eb3a9da97e53cee14e585e027badb3783b8e25e (patch) | |
| tree | 4840bc49cbde975289b3e3b663967a368b444f8b /src/playerid.rs | |
| parent | 13b53f3e89bcd6d33a534403162d1b09502bec70 (diff) | |
turned sprite, playerid and roomid into tuple structs
Diffstat (limited to 'src/playerid.rs')
| -rw-r--r-- | src/playerid.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/playerid.rs b/src/playerid.rs index 08e31d2..01de524 100644 --- a/src/playerid.rs +++ b/src/playerid.rs @@ -1,11 +1,12 @@ -#[derive(Debug, Default, PartialEq, Eq, Clone, Hash)] -pub struct PlayerId { - pub name: String -} +use std::fmt; +use serde::{Serialize, Deserialize}; + +#[derive(Debug, Default, PartialEq, Eq, Clone, Hash, Serialize, Deserialize)] +pub struct PlayerId(pub String); -impl PlayerId { - pub fn to_string(&self) -> String { - self.name.clone() +impl fmt::Display for PlayerId { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.0) } } |
