Skip to content

Commit 5deb647

Browse files
committed
cleaner impl
1 parent 15f6f70 commit 5deb647

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/smol_str/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ impl Clone for SmolStr {
111111
SmolStr(v.0.clone())
112112
}
113113

114-
if !self.is_heap_allocated() {
115-
// SAFETY: We verified that the payload of `Repr` is a POD
116-
return unsafe { core::ptr::read(self as *const SmolStr) };
114+
if self.is_heap_allocated() {
115+
return cold_clone(self);
117116
}
118117

119-
cold_clone(self)
118+
// SAFETY: We verified that the payload of `Repr` is a POD
119+
unsafe { core::ptr::read(self as *const SmolStr) }
120120
}
121121
}
122122

0 commit comments

Comments
 (0)