Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion genetic-rs-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ rayon = ["dep:rayon"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[package.metadata.docs.rs]
features = ["crossover", "speciation"]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ["cfg(docsrs)"] }

[dependencies]
itertools = { version = "0.14.0", optional = true }
rand = { version = "0.10.0", optional = true }
Expand Down
4 changes: 0 additions & 4 deletions genetic-rs-common/src/builtin/eliminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ mod knockout {
use super::*;

/// A distinct type to help clarify the result of a knockout function.
#[cfg_attr(docsrs, doc(cfg(feature = "knockout")))]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum KnockoutWinner {
/// The first genome parameter won.
Expand Down Expand Up @@ -325,7 +324,6 @@ mod knockout {
}

/// A function that pits two genomes against each other and determines a winner.
#[cfg_attr(docsrs, doc(cfg(feature = "knockout")))]
pub trait KnockoutFn<G> {
/// Tests the genomes to figure out who wins.
fn knockout(&self, a: &G, b: &G) -> KnockoutWinner;
Expand Down Expand Up @@ -383,7 +381,6 @@ mod knockout {
impl<G, T: KnockoutFn<G> + Send + Sync> FeatureBoundedKnockoutFn<G> for T {}

/// The action a knockout eliminator should take if the number of genomes is odd.
#[cfg_attr(docsrs, doc(cfg(feature = "knockout")))]
pub enum ActionIfOdd {
/// Always expect an even number, crash if odd.
Panic,
Expand Down Expand Up @@ -415,7 +412,6 @@ mod knockout {
}

/// Eliminator that pits genomes against each other and eliminates the weaker ones.
#[cfg_attr(docsrs, doc(cfg(feature = "knockout")))]
pub struct KnockoutEliminator<G: FeatureBoundedGenome, K: KnockoutFn<G>> {
/// The function that determines the winner of a pair of genomes.
pub knockout_fn: K,
Expand Down
4 changes: 0 additions & 4 deletions genetic-rs-common/src/builtin/repopulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ mod crossover {
use super::*;

/// Used in crossover-reproducing [`Repopulator`]s
#[cfg_attr(docsrs, doc(cfg(feature = "crossover")))]
pub trait Crossover: Clone {
/// Simulation-wide context required for this crossover implementation.
type Context;
Expand All @@ -107,7 +106,6 @@ mod crossover {
}

/// Repopulator that uses crossover reproduction to create new genomes.
#[cfg_attr(docsrs, doc(cfg(feature = "crossover")))]
pub struct CrossoverRepopulator<G: Crossover> {
/// The mutation rate to use when mutating genomes. 0.0 - 1.0
pub mutation_rate: f32,
Expand Down Expand Up @@ -166,7 +164,6 @@ mod speciation {
use super::*;

/// Used in speciated crossover nextgens. Allows for genomes to avoid crossover with ones that are too different.
#[cfg_attr(docsrs, doc(cfg(feature = "speciation")))]
pub trait Speciated {
/// The type used to distinguish
/// one genome's species from another.
Expand All @@ -177,7 +174,6 @@ mod speciation {
}

/// Repopulator that uses crossover reproduction to create new genomes, but only between genomes of the same species.
#[cfg_attr(docsrs, doc(cfg(feature = "speciation")))]
pub struct SpeciatedCrossoverRepopulator<G: Crossover + Speciated> {
/// The inner crossover repopulator. This holds the settings for crossover operations,
/// but may also be called if [`allow_emergency_repr`][Self::allow_emergency_repr] is `true`.
Expand Down
5 changes: 1 addition & 4 deletions genetic-rs-common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#![warn(missing_docs)]
#![allow(clippy::needless_doctest_main)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

//! The crate containing the core traits and structs of genetic-rs.

/// Built-in nextgen functions and traits to go with them.
#[cfg_attr(docsrs, doc(cfg(feature = "builtin")))]
#[cfg(feature = "builtin")]
pub mod builtin;

Expand Down Expand Up @@ -112,15 +111,13 @@ where

/// Helper trait used in the generation of random starting populations
#[cfg(feature = "genrand")]
#[cfg_attr(docsrs, doc(cfg(feature = "genrand")))]
pub trait GenerateRandom {
/// Create a completely random instance of the genome
fn gen_random(rng: &mut impl rand::Rng) -> Self;
}

/// Blanket trait used on collections that contain objects implementing [`GenerateRandom`]
#[cfg(feature = "genrand")]
#[cfg_attr(docsrs, doc(cfg(feature = "genrand")))]
pub trait GenerateRandomCollection<T>
where
T: GenerateRandom,
Expand Down
7 changes: 6 additions & 1 deletion genetic-rs-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ default = ["genrand", "crossover"]
crossover = ["genetic-rs-common/crossover"]
genrand = []

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ["cfg(docsrs)"] }

[dependencies]
darling = "0.23.0"
Expand Down
6 changes: 5 additions & 1 deletion genetic-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ derive = ["dep:genetic-rs-macros", "builtin"]
genetic-rs-common = { path = "../genetic-rs-common", version = "1.2.1", default-features = false }
genetic-rs-macros = { path = "../genetic-rs-macros", version = "1.2.1", optional = true }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ["cfg(publish)"] }
unexpected_cfgs = { level = "allow", check-cfg = ["cfg(publish)", "cfg(docsrs)"] }

[dev-dependencies]
rand = "0.10.0"
Expand Down
1 change: 1 addition & 0 deletions genetic-rs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(clippy::needless_doctest_main)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(publish, doc = include_str!(env!("CARGO_PKG_README")))]
#![cfg_attr(not(publish), doc = include_str!(concat!("../", env!("CARGO_PKG_README"))))]

Expand Down