Skip to content

Commit 4794774

Browse files
refactor: lint
1 parent 2a226a0 commit 4794774

File tree

4 files changed

+12
-28
lines changed

4 files changed

+12
-28
lines changed

packages/treetime-utils/src/file.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use eyre::{Report, WrapErr};
44
use log::info;
55
use std::fs::File;
66
use std::io::{BufRead, BufReader, BufWriter, Write, stdin, stdout};
7-
use std::path::{Path, PathBuf};
7+
use std::path::Path;
88

99
pub const DEFAULT_FILE_BUF_SIZE: usize = 256 * 1024;
1010

@@ -57,12 +57,12 @@ pub fn create_file_or_stdout(filepath: impl AsRef<Path>) -> Result<Box<dyn Write
5757

5858
pub fn is_path_stdin(filepath: impl AsRef<Path>) -> bool {
5959
let filepath = filepath.as_ref();
60-
filepath == PathBuf::from("-") || filepath == PathBuf::from("/dev/stdin")
60+
filepath == "-" || filepath == "/dev/stdin"
6161
}
6262

6363
pub fn is_path_stdout(filepath: impl AsRef<Path>) -> bool {
6464
let filepath = filepath.as_ref();
65-
filepath == PathBuf::from("-") || filepath == PathBuf::from("/dev/stdout")
65+
filepath == "-" || filepath == "/dev/stdout"
6666
}
6767

6868
#[cfg(not(target_arch = "wasm32"))]

packages/treetime/src/commands/ancestral/anc_args.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@ use std::path::PathBuf;
66

77
#[derive(Copy, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
88
#[value(rename_all = "kebab-case")]
9+
#[derive(Default)]
910
pub enum MethodAncestral {
11+
#[default]
1012
Joint,
1113
Marginal,
1214
Parsimony,
1315
}
1416

15-
impl Default for MethodAncestral {
16-
fn default() -> Self {
17-
Self::Joint
18-
}
19-
}
20-
2117
#[derive(Parser, Debug)]
2218
pub struct TreetimeAncestralArgs {
2319
/// Path to one or multiple FASTA files with aligned input sequences

packages/treetime/src/commands/timetree/args.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,37 @@ use std::path::PathBuf;
88

99
#[derive(Copy, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
1010
#[value(rename_all = "kebab-case")]
11+
#[derive(Default)]
1112
pub enum BranchLengthMode {
13+
#[default]
1214
Auto,
1315
Input,
1416
Joint,
1517
Marginal,
1618
}
1719

18-
impl Default for BranchLengthMode {
19-
fn default() -> Self {
20-
Self::Auto
21-
}
22-
}
23-
2420
#[derive(Copy, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
2521
#[value(rename_all = "kebab-case")]
22+
#[derive(Default)]
2623
pub enum TimeMarginalMode {
24+
#[default]
2725
Never,
2826
Always,
2927
OnlyFinal,
3028
}
3129

32-
impl Default for TimeMarginalMode {
33-
fn default() -> Self {
34-
Self::Never
35-
}
36-
}
37-
3830
#[derive(Copy, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
3931
#[value(rename_all = "kebab-case")]
32+
#[derive(Default)]
4033
pub enum RerootMode {
34+
#[default]
4135
LeastSquares,
4236
MinDev,
4337
Oldest,
4438
ClockFilter,
4539
Mrca,
4640
}
4741

48-
impl Default for RerootMode {
49-
fn default() -> Self {
50-
Self::LeastSquares
51-
}
52-
}
53-
5442
#[derive(Parser, Debug, SmartDefault)]
5543
pub struct TreetimeTimetreeArgs {
5644
/// Path to one or multiple FASTA files with aligned input sequences

packages/treetime/src/distribution/distribution_convolution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn convolution_range_function(r: &DistributionRange<f64>, f: &DistributionFuncti
8484
// - a point distribution (taking care of the shift + amplitude)
8585
// - an interval centered on zero and of a fixed width (taking care of the smoothing)
8686

87-
let shift = (r.start() + r.end()) / 2.0;
87+
let shift = f64::midpoint(r.start(), r.end());
8888
let amplitude = r.amplitude();
8989
let width = r.end() - r.start();
9090

0 commit comments

Comments
 (0)