Skip to content

Commit

Permalink
Merge pull request #48 from optuna/fix-lint-errors
Browse files Browse the repository at this point in the history
Fix clippy warnings
  • Loading branch information
sile committed Aug 16, 2022
2 parents dc19229 + e65ae59 commit 83ae97e
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
10 changes: 6 additions & 4 deletions kurobako_core/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ use crate::solver::{BoxSolverFactory, SolverRecipe};
use crate::{Error, Result};
use std::fmt;

type CreateProblemFactory =
dyn Fn(&JsonRecipe, &FactoryRegistry) -> Result<BoxProblemFactory> + Send;
type CreateSolverFactory = dyn Fn(&JsonRecipe, &FactoryRegistry) -> Result<BoxSolverFactory> + Send;

/// Factory registry.
pub struct FactoryRegistry {
create_problem_factory:
Box<dyn Fn(&JsonRecipe, &FactoryRegistry) -> Result<BoxProblemFactory> + Send>,
create_solver_factory:
Box<dyn Fn(&JsonRecipe, &FactoryRegistry) -> Result<BoxSolverFactory> + Send>,
create_problem_factory: Box<CreateProblemFactory>,
create_solver_factory: Box<CreateSolverFactory>,
}
impl FactoryRegistry {
/// Makes a new `FactoryRegistry` instance.
Expand Down
2 changes: 1 addition & 1 deletion kurobako_core/src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl ArcRng {
/// Makes a new `ArcRng` with the given random seed.
pub fn new(seed: u64) -> Self {
let mut seed256 = [0; 32];
(&mut seed256[0..8]).copy_from_slice(&seed.to_be_bytes());
seed256[0..8].copy_from_slice(&seed.to_be_bytes());

let inner = StdRng::from_seed(seed256);
Self(Arc::new(Mutex::new(inner)))
Expand Down
8 changes: 3 additions & 5 deletions kurobako_core/src/trial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,14 @@ impl PartialOrd for Values {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
let mut ord = None;
for (a, b) in self.0.iter().zip(other.0.iter()) {
if ord == None {
if ord.is_none() {
ord = a.partial_cmp(b);
if ord == None {
return None;
}
ord?;
} else if ord != a.partial_cmp(b) {
return None;
}
}
if ord == None {
if ord.is_none() {
Some(Ordering::Equal) // Both instances are empty.
} else {
ord
Expand Down
1 change: 1 addition & 0 deletions kurobako_problems/src/sigopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//! If you want to use an unimplemented function, please create an issue or PR.
//!
//! [sigopt/evalset]: https://github.com/sigopt/evalset
#![allow(clippy::format_push_string)]
use self::functions::TestFunction;
use kurobako_core::domain;
use kurobako_core::problem::{
Expand Down
2 changes: 1 addition & 1 deletion src/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl<'a, W: Write> MarkdownWriter<'a, W> {
}

pub fn inner_mut(&mut self) -> &mut W {
&mut self.writer
self.writer
}

pub fn newline(&mut self) -> Result<()> {
Expand Down
1 change: 1 addition & 0 deletions src/plot/curve.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! `kurobako plot curve` command.
#![allow(clippy::format_push_string)]
use super::{execute_gnuplot, normalize_filename};
use crate::record::{ProblemRecord, StudyRecord};
use indicatif::{ProgressBar, ProgressStyle};
Expand Down
1 change: 1 addition & 0 deletions src/plot/pareto_front.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! `kurobako plot pareto-front` command.
#![allow(clippy::format_push_string)]
use super::{execute_gnuplot, normalize_filename};
use crate::record::StudyRecord;
use indicatif::{ProgressBar, ProgressStyle};
Expand Down
1 change: 1 addition & 0 deletions src/plot/slice.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! `kurobako plot slice` command.
#![allow(clippy::format_push_string)]
use super::{execute_gnuplot, normalize_filename};
use crate::record::StudyRecord;
use indicatif::{ProgressBar, ProgressStyle};
Expand Down

0 comments on commit 83ae97e

Please sign in to comment.