From: Matt Corallo Date: Mon, 18 Apr 2022 02:56:05 +0000 (+0000) Subject: Make `Str`'s `clone` always clone the underlying bytes X-Git-Tag: v0.0.108.0~5^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=commitdiff_plain;h=8f3b8e4b52275f738016a4d1bbc8a0e9be90039e Make `Str`'s `clone` always clone the underlying bytes Its incredibly unexpected that you can clone a higher-level object (eg an Event with a ClosureReason that contains an `Str`) and have a pointer back to the original object. To avoid this, `clone` needs to actually `clone`. --- diff --git a/lightning-c-bindings/src/c_types/mod.rs b/lightning-c-bindings/src/c_types/mod.rs index 1e88f05..12c7088 100644 --- a/lightning-c-bindings/src/c_types/mod.rs +++ b/lightning-c-bindings/src/c_types/mod.rs @@ -569,7 +569,7 @@ impl Into for String { } impl Clone for Str { fn clone(&self) -> Self { - self.into_str().clone().into() + String::from(self.into_str()).into() } }