Skip to content

Commit f891304

Browse files
committed
Appease Clippy
1 parent ec804ee commit f891304

File tree

11 files changed

+51
-46
lines changed

11 files changed

+51
-46
lines changed

flatgfa-py/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl ListRef {
169169
{
170170
match arg {
171171
SliceOrInt::Slice(slice) => {
172-
let indices = slice.indices(self.len().try_into().unwrap())?;
172+
let indices = slice.indices(self.len().into())?;
173173
if indices.step == 1 {
174174
Ok(L::from(self.slice(indices.start as u32, indices.stop as u32)).into_py(py))
175175
} else {
@@ -547,7 +547,7 @@ impl StepList {
547547
fn __getitem__(&self, arg: SliceOrInt, py: Python) -> PyResult<PyObject> {
548548
match arg {
549549
SliceOrInt::Slice(slice) => {
550-
let indices = slice.indices(self.0.len().try_into().unwrap())?;
550+
let indices = slice.indices(self.0.len().into())?;
551551
if indices.step == 1 {
552552
let list = self.0.slice(indices.start as u32, indices.stop as u32);
553553
Ok(Self(list).into_py(py))

flatgfa/src/cli/cmds.rs

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -271,32 +271,30 @@ pub fn gaf_lookup(gfa: &flatgfa::FlatGFA, args: GAFLookup) {
271271
} else {
272272
unimplemented!("only the no-op mode is parallel")
273273
}
274-
} else {
275-
if args.seqs {
276-
// Print the actual sequences for each chunk in the GAF.
277-
for read in parser {
278-
print!("{}\t", read.name);
279-
for event in ops::gaf::PathChunker::new(gfa, &name_map, read) {
280-
event.print_seq(gfa);
281-
}
282-
println!();
274+
} else if args.seqs {
275+
// Print the actual sequences for each chunk in the GAF.
276+
for read in parser {
277+
print!("{}\t", read.name);
278+
for event in ops::gaf::PathChunker::new(gfa, &name_map, read) {
279+
event.print_seq(gfa);
283280
}
284-
} else if args.bench {
285-
// Benchmarking mode: just process all the chunks but print nothing.
286-
let mut count = 0;
287-
for read in parser {
288-
for _event in ops::gaf::PathChunker::new(gfa, &name_map, read) {
289-
count += 1;
290-
}
281+
println!();
282+
}
283+
} else if args.bench {
284+
// Benchmarking mode: just process all the chunks but print nothing.
285+
let mut count = 0;
286+
for read in parser {
287+
for _event in ops::gaf::PathChunker::new(gfa, &name_map, read) {
288+
count += 1;
291289
}
292-
println!("{}", count);
293-
} else {
294-
// Just print some info about the offsets in the segments.
295-
for read in parser {
296-
println!("{}", read.name);
297-
for event in ops::gaf::PathChunker::new(gfa, &name_map, read) {
298-
event.print(gfa);
299-
}
290+
}
291+
println!("{}", count);
292+
} else {
293+
// Just print some info about the offsets in the segments.
294+
for read in parser {
295+
println!("{}", read.name);
296+
for event in ops::gaf::PathChunker::new(gfa, &name_map, read) {
297+
event.print(gfa);
300298
}
301299
}
302300
}

flatgfa/src/file.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::repr_packed_without_abi)]
2+
13
use crate::flatgfa;
24
use crate::pool::{FixedStore, Pool, Span, Store};
35
use std::mem::{size_of, size_of_val};

flatgfa/src/flatgfa.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::repr_packed_without_abi)]
2+
13
use std::ops::Range;
24
use std::str::FromStr;
35

@@ -174,7 +176,7 @@ impl Handle {
174176
assert!(seg_num & (1 << (u32::BITS - 1)) == 0, "index too large");
175177
let orient_bit: u8 = orient.into();
176178
assert!(orient_bit & !1 == 0, "invalid orientation");
177-
Self(seg_num << 1 | (orient_bit as u32))
179+
Self((seg_num << 1) | (orient_bit as u32))
178180
}
179181

180182
/// Get the segment ID. This is an index in the `segs` pool.
@@ -311,7 +313,7 @@ fn nucleotide_complement(c: u8) -> u8 {
311313
}
312314
}
313315

314-
impl<'a> std::fmt::Display for Sequence<'a> {
316+
impl std::fmt::Display for Sequence<'_> {
315317
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
316318
if self.revcmp {
317319
// For small sequences, it's faster to allocate the reverse-complement

flatgfa/src/gfaline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl<'a> StepsParser<'a> {
227227
}
228228
}
229229

230-
impl<'a> Iterator for StepsParser<'a> {
230+
impl Iterator for StepsParser<'_> {
231231
type Item = (usize, bool);
232232
fn next(&mut self) -> Option<(usize, bool)> {
233233
while self.index < self.str.len() {

flatgfa/src/memfile.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub fn map_new_file(name: &str, size: u64) -> MmapMut {
1313
let file = std::fs::OpenOptions::new()
1414
.read(true)
1515
.write(true)
16+
.truncate(true)
1617
.create(true)
1718
.open(name)
1819
.unwrap();

flatgfa/src/ops/bench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rayon::iter::ParallelIterator;
33

44
// Count the lines in a file, like `wc -l`.
55
pub fn line_count(filename: &str, parallel: bool) -> usize {
6-
let buf = memfile::map_file(&filename);
6+
let buf = memfile::map_file(filename);
77
let split = memfile::MemchrSplit::new(b'\n', &buf);
88
if parallel {
99
ParallelIterator::count(split)

flatgfa/src/ops/gaf.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<'a> GAFLineParser<'a> {
4242

4343
fn int_field(&mut self) -> Option<usize> {
4444
let mut pos = 0;
45-
let val = parse_int(&self.buf, &mut pos);
45+
let val = parse_int(self.buf, &mut pos);
4646
assert!(matches!(self.buf[pos], b'\t' | b'\n'));
4747
self.advance(pos + 1);
4848
val
@@ -193,7 +193,7 @@ impl ChunkEvent {
193193
}
194194
}
195195

196-
impl<'a, 'b> Iterator for PathChunker<'a, 'b> {
196+
impl Iterator for PathChunker<'_, '_> {
197197
type Item = ChunkEvent;
198198

199199
fn next(&mut self) -> Option<ChunkEvent> {
@@ -278,13 +278,13 @@ fn parse_int(bytes: &[u8], index: &mut usize) -> Option<usize> {
278278
}
279279

280280
if first_digit {
281-
return None;
281+
None
282282
} else {
283-
return Some(num);
283+
Some(num)
284284
}
285285
}
286286

287-
impl<'a> Iterator for PathParser<'a> {
287+
impl Iterator for PathParser<'_> {
288288
type Item = (usize, bool);
289289

290290
fn next(&mut self) -> Option<(usize, bool)> {
@@ -303,7 +303,7 @@ impl<'a> Iterator for PathParser<'a> {
303303

304304
// Parse the integer segment name.
305305
let seg_name = parse_int(self.str, &mut self.index)?;
306-
return Some((seg_name, forward));
306+
Some((seg_name, forward))
307307
}
308308
}
309309

flatgfa/src/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl<'a, P: flatgfa::StoreFamily<'a>> Parser<'a, P> {
148148

149149
fn add_path(&mut self, path: gfaline::Path) {
150150
// Parse the steps.
151-
let mut step_parser = gfaline::StepsParser::new(&path.steps);
151+
let mut step_parser = gfaline::StepsParser::new(path.steps);
152152
let steps = self.flat.add_steps((&mut step_parser).map(|(name, dir)| {
153153
Handle::new(
154154
self.seg_ids.get(name),

flatgfa/src/pool.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::repr_packed_without_abi)]
2+
13
use std::ops::{Add, Index, Sub};
24
use std::{hash::Hash, marker::PhantomData};
35
use tinyvec::SliceVec;
@@ -195,7 +197,7 @@ impl<T> Default for HeapStore<T> {
195197
#[repr(transparent)]
196198
pub struct FixedStore<'a, T>(SliceVec<'a, T>);
197199

198-
impl<'a, T: Clone> Store<T> for FixedStore<'a, T> {
200+
impl<T: Clone> Store<T> for FixedStore<'_, T> {
199201
fn as_ref(&self) -> Pool<T> {
200202
Pool(&self.0)
201203
}
@@ -223,7 +225,7 @@ impl<'a, T: Clone> Store<T> for FixedStore<'a, T> {
223225
}
224226
}
225227

226-
impl<'a, T> FixedStore<'a, T> {
228+
impl<T> FixedStore<'_, T> {
227229
pub fn capacity(&self) -> usize {
228230
self.0.capacity()
229231
}

0 commit comments

Comments
 (0)