You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently when deriving EncodeLabelSet and flattening a struct the flattened struct must appear last, and there must be only one flattened struct, from the test:
error[E0382]: borrow of moved value: `encoder`
--> derive-encode/tests/lib.rs:147:14
|
147 | #[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)]
| ^^^^^^^^^^^^^^
| |
| value borrowed here after move
| move occurs because `encoder` has type `LabelSetEncoder<'_>`, which does not implement the `Copy` trait
|
I think this would be a breaking change to fix, but fixing it would allow fields to appear in any order, or allow flattening of multiple structs without nesting them all one inside the other in tail position.
The text was updated successfully, but these errors were encountered:
I think this would be a breaking change to fix, but fixing it would allow fields to appear in any order, or allow flattening of multiple structs without nesting them all one inside the other in tail position.
Worth exploring passing &mut LabelSetEncoder. Not sure why I chose to require ownership.
Another alternative is to provide a better error message in the derive macro when the flattened property is not the last.
My initial impression is that this would be a welcome API change. If we could impl<A: EncodeLabelSet, B: EncodeLabelSet> EncodeLabelSet for (A, B), that would generally make label composition more flexible.
Currently when deriving
EncodeLabelSet
and flattening a struct the flattened struct must appear last, and there must be only one flattened struct, from the test:If you place
common
beforeunique
instruct Labels
like this:Compilation fails:
This occurs because ownership of
encoder
is given to the flattened structI think this would be a breaking change to fix, but fixing it would allow fields to appear in any order, or allow flattening of multiple structs without nesting them all one inside the other in tail position.
The text was updated successfully, but these errors were encountered: