Layout
extension trait
#627
Merged
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.
The intent here is to provide a
LayoutExt
extension trait for types that have aLayout
member, to provide them with type aliases and methods on them, e.g. "owned key", "borrowed key", "borrowed to owned function".This seems to work, but .. there are some mysterious edits needed to unlock the type inference. On that stood out was changing a
Tr: Trace + TraceReader< ... >
bound into aTr: Trace< ...>
bound. No idea why Rust needed the constraints in that trait, wheretrait Trace : TraceReader
. Perhaps they need to be in the trait at the top of the stack rather than halfway through; I couldn't say.Hesitant to merge without a better understanding of what is going on, and how much maintenance peril we are in. It's all a bit silly because all we are trying to say is "everyone has the same
L: Layout
", and .. perhaps the right thing to do is just to add it as a trait argument, e.g.Trace<L>
,Batch<L>
,Cursor<L>
, and life could be better. Though at the same time it really is an associated type: each trait implementations has a single layout in mind.