diff options
Diffstat (limited to 'users/tazjin/german-string/src/lib.rs')
-rw-r--r-- | users/tazjin/german-string/src/lib.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/users/tazjin/german-string/src/lib.rs b/users/tazjin/german-string/src/lib.rs index 5cc8aebaab96..328eca309f38 100644 --- a/users/tazjin/german-string/src/lib.rs +++ b/users/tazjin/german-string/src/lib.rs @@ -295,6 +295,26 @@ impl Debug for GermanString { } } +impl Clone for GermanString { + fn clone(&self) -> Self { + unsafe { + if self.len() <= 12 { + return GermanString(GSRepr { + small: self.0.small.clone(), + }); + } + + if self.0.large.data.is_transient() { + return GermanString::transient(self.as_bytes()); + } + + return GermanString(GSRepr { + large: self.0.large.clone(), + }); + } + } +} + #[cfg(test)] mod tests { use super::*; |