-
Notifications
You must be signed in to change notification settings - Fork 157
Closed
Description
Problem
The new PartialEq implementation on Address will break match-against-const contexts (incl. in agave here), as StructuralPartialEq can no longer be auto-derived.
This also breaks other similar patterns such as if let against constant.
Rust doesn't allow constants to be used as patterns for matching when PartialEq is hand-implemented - since that could, for example, expose private implementation details.
Solutions
There are a few options here, including these briefly-considered possibilities:
- require dependents to avoid
matchpatterns against constants (and document this), which makes some semantic sense forAddress - restore
derive(PartialEq)and move the custom equality logic back behind a separate method/trait, as before - require dependents wishing to
matchagainst constants to use a new simple helper that exposes a#[derive(PartialEq)]type - assorted solutions that split the type, such as raw and wrapper
impl StructuralPartialEq, but who knows when that will be stable
For now, I'm adapting agave code when needed, e.g. switching match to if/else or guarded match patterns.
grod220
Metadata
Metadata
Assignees
Labels
No labels