Skip to content

Commit

Permalink
refactor: use .first instead of get(0)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyAB committed Dec 28, 2023
1 parent 07dca6a commit cf9c1e3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/genetics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ impl Population {
if individual_fitness_map.len() <= 1 {
println!("The whole population died. Restarting from scratch");
return Population::genesis(
self.individuals
.get(0)
self.individuals.first()
.expect("A generation should always contain individuals")
.literals
.len(),
Expand Down Expand Up @@ -218,8 +217,7 @@ pub fn optimize(
let mut population = Population::genesis(formula.number_of_literals, population_size);
let mut all_time_best_fitness = 0_f64;
let mut all_time_best_individual = population
.individuals
.get(0)
.individuals.first()
.expect("Initial population should at least have a single individual")
.clone();

Expand Down

0 comments on commit cf9c1e3

Please sign in to comment.