diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-04 14:44:50 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-04 14:51:35 +0800 |
| commit | 9a231d8c163414d462a185d955e6887b64704802 (patch) | |
| tree | c6fe3d0227ab76046b8e0c32c3665a5a9a604817 /mingling_core/src/metadata/description.rs | |
| parent | b5e14df41a2b77d71e3367fe44bf466f5c8ad1b5 (diff) | |
refactor(metadata): move metadata module to core crate
Diffstat (limited to 'mingling_core/src/metadata/description.rs')
| -rw-r--r-- | mingling_core/src/metadata/description.rs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/mingling_core/src/metadata/description.rs b/mingling_core/src/metadata/description.rs new file mode 100644 index 0000000..48bf095 --- /dev/null +++ b/mingling_core/src/metadata/description.rs @@ -0,0 +1,57 @@ +/// Provides a description for any Grouped type. +pub struct Description { + desc: String, +} + +impl Description { + /// Creates a new `Description` instance. + pub fn new<S: Into<String>>(desc: S) -> Self { + Self { desc: desc.into() } + } +} + +impl From<String> for Description { + fn from(desc: String) -> Self { + Self { desc } + } +} + +impl From<&str> for Description { + fn from(desc: &str) -> Self { + Self { + desc: desc.to_string(), + } + } +} + +impl From<Description> for String { + fn from(desc: Description) -> Self { + desc.desc + } +} + +impl From<&Description> for String { + fn from(desc: &Description) -> Self { + desc.desc.clone() + } +} + +impl std::ops::Deref for Description { + type Target = str; + + fn deref(&self) -> &Self::Target { + &self.desc + } +} + +impl std::ops::DerefMut for Description { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.desc + } +} + +impl std::fmt::Display for Description { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.desc) + } +} |
