refactor: modernize arithmetic, control flow, and error handling
Replace manual ceiling division with `div_ceil`, update `map_or` patterns to `is_some_and`/`is_ok_and`, and simplify error handling across the codebase. Move the `default` function for `GraphDeBruijn` from the index layer module to the De Bruijn graph module. - Move `default` from `src/obikindex/src/layer/meta.rs` to `src/obidebruinj/src/debruijn/graph.rs` and implement `Default` for `GraphDeBruijn` - Simplify `IndexBuilder::state`, `KmerIndex::genomes`, and `n_layers_per_partition` in `src/obikindex` by removing redundant `Ok` wrappers - Replace manual ceiling division with `div_ceil` in `src/obikindex/src/layer/fingerprint.rs` for data slicing and byte calculations - Update `Mphf` operations in `src/obikindex/src/layer/mphf_layer.rs` to use `mmap`, `load_full`, and `store` directly, and switch size calculations to `div_ceil` - Refine `IndexMode` in `src/obikindex/src/layer/meta.rs` to derive `Default` with `#[default]` on `Exact` - Update `count_partition` in `src/obikindexer/src/algorithms/counter/count.rs` to use `io::Error::other` with string conversion for error mapping - Switch `optimal_buckets` in `src/obikindexer/src/algorithms/dereplicator/dereplicate.rs` to use `div_ceil` for average sequence bytes and bucket estimation - Replace `max_or` and `map_or` with `is_none_or` and direct checks in `src/obikindexer/src/extensions/private_builder.rs` for layer building and artifact removal - Enforce odd k-mer and minimizer sizes in `src/obikmer/src/cli.rs` using `is_multiple_of` and update validation ranges - Update `resolve_approx_params` in `src/obikmer/src/cmd/index/mod.rs` to use `div_ceil` for parameter calculations - Add documentation for `DistanceArg` in `src/obikmer/src/cmd/phylo/values.rs` and clean up test modules - Refactor median calculation in `src/obikmer/src/cmd/utils/partition_stats.rs` to explicitly handle even and odd lengths - Replace `g.len() > 0` with `!g.is_empty()` in `src/obikmerge/src/partition_merge/mod.rs` - Use `isolate_lowest_one` in `src/obikphylo/src/siblings/algorithms/alignment_vcf.rs` for diploid allele calculation - Add documentation for `family_entropy` in `src/obikphylo/src/siblings/algorithms/entropy.rs` and remove empty test blocks - Replace `map_or` with `is_some_and` in `src/obikquery/src/findere.rs` and `src/obikquery/src/tests/findere.rs` for deque pruning logic - Simplify `remove_if_exists` in `src/obikrebuild/src/reindex.rs` to warn only on non-`NotFound` errors - Store `mime_type` by value in `src/obikrope/src/rope.rs` and update `mime_type` and `split_off` accordingly - Replace manual ceiling division with `div_ceil` in `src/obikseq/src/packed_seq.rs` for byte length and iteration logic - Update `build_dec4` in `src/obikseq/src/encoding.rs` to use a string slice literal for the decode table - Refactor `revcomp4` in `src/obikseq/src/revcomp_lookup.rs` to use `rotate_left` for nibble swapping - Simplify `run` in `src/obipipeline/src/scheduler/pool.rs` to use `if let Ok` for delta handling - Simplify MIME type checking in `src/obiread/src/chunk.rs` and update error handling for unsupported formats - Replace `map_or` with `is_ok_and` in `src/obiread/src/mimetype.rs` for FASTA/FASTQ detection - Update `normalize_fastq` and related functions in `src/obiread/src/normalize.rs` to handle `Result` returns from cursor reads - Simplify `skip_line` in `src/obiread/src/record.rs` to check `Ok` results directly - Simplify test assertions in `src/obiread/src/tests/chunk.rs` by removing unnecessary closures - Update `http_reader` in `src/obiread/src/xopen.rs` to map errors to `io::Error::other` and refine `expand_tilde` logic - Refactor minimizer change detection in `src/obiskbuilder/src/iter.rs` and `src/obiskbuilder/src/stream_iter.rs` to explicitly check `Some` and inequality - Update `push` in `src/obiskbuilder/src/rolling_stat.rs` to use `is_some_and` for hash and position checks - Replace manual ceiling division with `div_ceil` in `src/obiskbuilder/src/scratch.rs` for buffer slicing - Update `next` in `src/obiskio/src/unitig_index/kmer_iter.rs` to use `div_ceil` for byte length calculation - Replace manual ceiling division with `div_ceil` in `src/obiskio/src/unitig_index/kmer_raw.rs` for byte extraction - Update `src/obiskio/src/unitig_index/reader.rs` to use `div_ceil` for byte lengths and direct comparison for magic bytes - Replace manual ceiling division with `div_ceil` in `src/obiskio/src/unitig_index/writer.rs` for chunk and index writing - Simplify CPU set mapping in `src/obisys/src/numa/topology.rs` by removing explicit type annotations - Update `stop` in `src/obisys/src/stage.rs` to use direct delta comparisons for fault counts - Refine `matches` in `src/obitaxonomy/src/segment_pattern.rs` to check for inequality when rank is `None`
This commit is contained in:
1 parent
ed0d563995
commit
f022d83394
42 files changed
+202
-215
No files matched your search
@@ -63,7 +63,7 @@ impl Rope {
|
||||
|
||||
/// The MIME type of the rope, if known.
|
||||
pub fn mime_type(&self) -> Option<&str> {
|
||||
self.mime_type.as_deref()
|
||||
self.mime_type
|
||||
}
|
||||
|
||||
/// Total number of blocks.
|
||||
@@ -122,7 +122,7 @@ impl Rope {
|
||||
}
|
||||
|
||||
if pos == self.length {
|
||||
return Ok(Rope::new(self.mime_type.clone()));
|
||||
return Ok(Rope::new(self.mime_type));
|
||||
}
|
||||
|
||||
let (block_idx, from, _) = self.lookup(pos).ok_or_else(|| {
|
||||
@@ -156,7 +156,7 @@ impl Rope {
|
||||
self.length = pos;
|
||||
|
||||
Ok(Rope {
|
||||
mime_type: self.mime_type.clone(),
|
||||
mime_type: self.mime_type,
|
||||
blocks: tail_blocks,
|
||||
length: tail_length,
|
||||
start_block_idx: tail_starts,
|
||||
|
||||
Reference in new issue
Block a user