From 8f3b8e4b52275f738016a4d1bbc8a0e9be90039e Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 18 Apr 2022 02:56:05 +0000 Subject: [PATCH] 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`. --- lightning-c-bindings/src/c_types/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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() } } -- 2.39.5