Skip to content

Add QoL trait impls to LayeredObserver - #147

Merged
HyperCodec merged 3 commits into
devfrom
copilot/add-extra-traits-to-layered-observer
Mar 10, 2026
Merged

HyperCodec merged 3 commits into
devfrom
copilot/add-extra-traits-to-layered-observer

Conversation

Copilot AI commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

LayeredObserver<G, A, B> lacked standard trait derivations, making it awkward to use in contexts requiring default construction, cloning, equality checks, or debug formatting.

Changes

  • Default — constructs via A::default() and B::default()
  • Clone — deep-clones both inner observers
  • Debug — formats as LayeredObserver(a, b)
  • PartialEq / Eq — delegates equality to both inner observers

All impls are conditional on A and B satisfying the respective bound — no constraints imposed on G.

Example

#[derive(Default, Clone, Debug, PartialEq)]
struct MyObserver;

impl<G> FitnessObserver<G> for MyObserver { /* ... */ }

// Now works:
let observer = MyObserver.layer(MyObserver);
let cloned = observer.clone();
let default: LayeredObserver<(), MyObserver, MyObserver> = LayeredObserver::default();
assert_eq!(observer, cloned);
println!("{:?}", default); // LayeredObserver(MyObserver, MyObserver)
Original prompt

This section details on the original issue you should resolve

<issue_title>Add some extra traits to LayeredObserver</issue_title>
<issue_description>Can do something like this:

impl<G, A, B> Default for LayeredObserver<G, A, B>
where
    A: Default + FitnessObserver<G>,
    B: Default + FitnessObserver<G>,
{
    fn default() -> Self {
        Self(A::default(), B::default());
    }
}
```</issue_description>

<agent_instructions>Add whatever traits you feel would be convenient for QoL.</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: HyperCodec <72839119+HyperCodec@users.noreply.github.com>
Copilot AI changed the title [WIP] Add extra traits to LayeredObserver for convenience Add QoL trait impls to LayeredObserver Mar 10, 2026
@HyperCodec
HyperCodec marked this pull request as ready for review March 10, 2026 12:15

@HyperCodec HyperCodec left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh I don't really see why tests are necessary for such a trivial change, but sure.

@HyperCodec
HyperCodec merged commit abcb120 into dev Mar 10, 2026
3 checks passed
@HyperCodec
HyperCodec deleted the copilot/add-extra-traits-to-layered-observer branch March 10, 2026 12:17

This branch was previously deployed

1 inactive deployment
testing a7bfefe5 Deployed Mar 10, 2026 by HyperCodec via Unit Testing #235
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants