From e2ec208cec1ede3d05974da79c2bcd3c13088aca Mon Sep 17 00:00:00 2001 From: Rigidity Date: Fri, 17 Nov 2023 11:30:01 -0500 Subject: [PATCH] Add comment explaining `clone_node` --- clvm-traits/src/clvm_decoder.rs | 3 +++ clvm-traits/src/clvm_encoder.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/clvm-traits/src/clvm_decoder.rs b/clvm-traits/src/clvm_decoder.rs index 1a822a198..75c63d037 100644 --- a/clvm-traits/src/clvm_decoder.rs +++ b/clvm-traits/src/clvm_decoder.rs @@ -11,6 +11,9 @@ pub trait ClvmDecoder { fn decode_atom(&self, node: &Self::Node) -> Result<&[u8], FromClvmError>; fn decode_pair(&self, node: &Self::Node) -> Result<(Self::Node, Self::Node), FromClvmError>; + /// This is a helper function that just calls `clone` on the node. + /// It's required only because the compiler can't infer that `N` is `Clone`, + /// since there's no `Clone` bound on the `FromClvm` trait. fn clone_node(&self, node: &Self::Node) -> Self::Node { node.clone() } diff --git a/clvm-traits/src/clvm_encoder.rs b/clvm-traits/src/clvm_encoder.rs index 8e000d1b8..f65812cb8 100644 --- a/clvm-traits/src/clvm_encoder.rs +++ b/clvm-traits/src/clvm_encoder.rs @@ -12,6 +12,9 @@ pub trait ClvmEncoder { rest: Self::Node, ) -> Result; + /// This is a helper function that just calls `clone` on the node. + /// It's required only because the compiler can't infer that `N` is `Clone`, + /// since there's no `Clone` bound on the `ToClvm` trait. fn clone_node(&self, node: &Self::Node) -> Self::Node { node.clone() }