Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fitness trait #99

Merged
merged 1 commit into from
Jan 30, 2025
Merged

Add Fitness trait #99

merged 1 commit into from
Jan 30, 2025

Conversation

dbalcomb
Copy link
Contributor

This adds a new Fitness trait that is different to the previous Fitness trait.

The Fitness trait was originally introduced in #29 as an extension to the Individual trait to provide a new fitness method. The trait was named after the method but didn't quite fit the naming conventions in this crate or the wider Rust ecosystem. At the time it seemed preferable to WithFitness, Fit, Score, or any other option. Now that the Fitness trait has been merged with the Individual trait in #97 the name is free to be repurposed.

This change introduces a new Fitness trait that represents the value instead of an individual with a fitness. The trait has a single method nil which was chosen based on the Nil fitness from #98 and to avoid conflicting with the zero method from the Zero trait. Unfortunately types such as Reverse do not implement Zero and it required Add so that was not an option. The Default trait was ruled out because that may imply a non-zero value. However, nil may suggest no value rather than a zero value so there is no clear option. At the very least the method justifies the existence of the trait.

This also updates various trait bounds to replace Default with Fitness and updates the associated Fitness in the Individual trait to add a new bound.

@dbalcomb dbalcomb added package: brace-ec Affects the `brace-ec` package change: feature A new feature labels Jan 30, 2025
@dbalcomb dbalcomb merged commit 46869f7 into main Jan 30, 2025
5 checks passed
@dbalcomb dbalcomb deleted the feature/add-fitness-trait branch January 30, 2025 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change: feature A new feature package: brace-ec Affects the `brace-ec` package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant