Derive Copy and Clone HeaderSlice and HeaderWithLength #92
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.
We (apollo-compiler) have an AST where most nodes are wrapped in, approximately:
Arc
allows subtrees to be shared without deep cloning, andArc::make_mut
is used extensively for mutability with clone-on-write semantics.Now I would like to also support
Node<str>
and rely onArc::from_header_and_str
for the unsafe bits. This requires usingHeaderSlice
which with triomphe v0.1.12 breaksArc::make_mut
because it does not implementClone
. This PR fixes that.Clone
cannot work forT: !Sized
which is the main use case forHeaderSlice
but that’s ok,derive
automatically insert the appropriatewhere
bound. This is still useful in order to have the sameNode<T>
useHeaderSlice
to support bothT: Sized
andT: !Sized
. (The names ofHeaderSlice
and itsslice
field are weird whenT: Sized
but that weirdness is contained in the module definingstruct Node
.)While I don’t have a use for this today this PR also derives
Copy
, and givesHeaderWithLength
the same treatment.