File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
deep_causality_ast/src/const_tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -11,3 +11,10 @@ impl<T> From<T> for ConstTree<T> {
1111 Self :: new ( value)
1212 }
1313}
14+ // Egonomics for creating a leaf node from a reference,
15+ impl < T : Clone > From < & T > for ConstTree < T > {
16+ /// Creates a new leaf `ConstTree` by cloning the provided value.
17+ fn from ( value : & T ) -> Self {
18+ Self :: new ( value. clone ( ) )
19+ }
20+ }
Original file line number Diff line number Diff line change @@ -106,10 +106,10 @@ impl<T> ConstTree<T> {
106106 /// // The children are shared between the two trees.
107107 /// assert!(original.children()[0].ptr_eq(&with_new_value.children()[0]));
108108 /// ```
109- pub fn with_value ( & self , new_value : T ) -> Self {
109+ pub fn with_value < V : Into < T > > ( & self , new_value : V ) -> Self {
110110 Self {
111111 node : Arc :: new ( Node {
112- value : new_value,
112+ value : new_value. into ( ) ,
113113 children : self . node . children . clone ( ) ,
114114 } ) ,
115115 }
You can’t perform that action at this time.
0 commit comments