diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-04-16 21:31:57 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-04-16 21:31:57 +0800 |
| commit | 363fbc6e98f832471a17a10ec18e8823df6a2ed5 (patch) | |
| tree | 98f71ab1796c1a9c1df411eee5174dd92001ef94 /src/who.rs | |
Initialize Rust project with billing calculation functionality
Diffstat (limited to 'src/who.rs')
| -rw-r--r-- | src/who.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/who.rs b/src/who.rs new file mode 100644 index 0000000..9d6e5b5 --- /dev/null +++ b/src/who.rs @@ -0,0 +1,44 @@ +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct Who { + name: String, +} + +impl std::ops::Deref for Who { + type Target = String; + + fn deref(&self) -> &Self::Target { + &self.name + } +} + +impl std::ops::DerefMut for Who { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.name + } +} + +impl From<String> for Who { + fn from(s: String) -> Self { + Who { name: s } + } +} + +impl From<&str> for Who { + fn from(s: &str) -> Self { + Who { + name: s.to_string(), + } + } +} + +impl Into<String> for Who { + fn into(self) -> String { + self.name + } +} + +impl std::fmt::Display for Who { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.name) + } +} |
