Skip to content

Commit

Permalink
style: fix lints (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen authored Feb 3, 2025
1 parent 30edbae commit 8284042
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ homepage = "https://github.com/ForwardSimulation/forrustts"
repository = "https://github.com/ForwardSimulation/forrustts"
keywords = ["simulation", "tree_sequences", "tskit", "population_genetics"]

# Added for rust >= 1.80.0
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_cfg)'] }

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

[workspace]
members = [
Expand Down
1 change: 0 additions & 1 deletion forrustts-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![warn(missing_docs)]
#![warn(rustdoc::broken_intra_doc_links)]
#![cfg_attr(doc_cfg, feature(doc_cfg))]

use thiserror::Error;

Expand Down
18 changes: 11 additions & 7 deletions forrustts-genetics/src/genetic_maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ pub enum Breakpoint {
IndependentAssortment(Position),
}

impl Breakpoint {
fn as_position(&self) -> Position {
match self {
Breakpoint::IndependentAssortment(p) => *p,
Breakpoint::Crossover(p) => *p,
}
}
}

impl From<Breakpoint> for Position {
fn from(value: Breakpoint) -> Self {
match value {
Breakpoint::IndependentAssortment(p) => p,
Breakpoint::Crossover(p) => p,
}
value.as_position()
}
}

impl PartialOrd for Breakpoint {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
let left = Position::from(*self);
let right = Position::from(*other);
left.partial_cmp(&right)
Some(self.as_position().cmp(&other.as_position()))
}
}

Expand Down
28 changes: 14 additions & 14 deletions forrustts-genetics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ pub use genetic_maps::GeneticMapStatus;
pub use genetic_maps::IndependentAssortment;
pub use genetic_maps::PoissonCrossover;

#[cfg(test)]
mod tests {
use super::*;
use rand::Rng;

struct MyGeneticMap {}

impl GenerateBreakpoints for MyGeneticMap {
fn generate_breakpoints<T: Rng>(&mut self, _rng: &mut T) {}
fn breakpoints(&self) -> &[Breakpoint] {
&[]
}
}
}
// #[cfg(test)]
// mod tests {
// use super::*;
// use rand::Rng;
//
// struct MyGeneticMap {}
//
// impl GenerateBreakpoints for MyGeneticMap {
// fn generate_breakpoints<T: Rng>(&mut self, _rng: &mut T) {}
// fn breakpoints(&self) -> &[Breakpoint] {
// &[]
// }
// }
// }

#[test]
fn test_poisson_crossover() {
Expand Down

0 comments on commit 8284042

Please sign in to comment.