PrintTree and RoundTree: use Layout instead of &Layout #849
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
This PR allows the use of
PrintTreeandRoundTreefor smart pointer interfaced trees.Let me know how is best to update the changelog if you need me to.
Context
In my use of taffy, I need my tree implementation to be within a
RefCell<T>. This is already possible with most tree traits, as they have generic associated types implementing traits such asCoreStyle, so I can make a newtype overRef<'a, Style>withRef::mapand make it work. However,RoundTreeandPrintTreedo not allow this, as they return a plain&Layoutreference instead of an associated type.I looked in the code, and in the tree rounding code, the
&Layoutis already copied. Additionally, printing the tree is likely more of a debugging or testing feature, so I feel that copying is warranted here instead of having to introduce some sort of new trait likeCoreStyleforLayoutwhich would potentially break more code internally.