From fc8372582bcfc61dd6389fbfe8ab47fd0640b570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20K=C3=B6ppl?= Date: Mon, 5 Feb 2024 12:08:21 +0900 Subject: [PATCH] lint --- src/bin/count_z.rs | 2 -- src/bin/escape.rs | 16 +++++++++++++--- src/bin/is_stringattractor.rs | 3 +-- src/core.rs | 5 ++++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/bin/count_z.rs b/src/bin/count_z.rs index 8dc6681..749b273 100644 --- a/src/bin/count_z.rs +++ b/src/bin/count_z.rs @@ -63,7 +63,6 @@ fn compute_lz77( debug_assert_eq!( ret, (psv_sa_position + 1..sa_position + 1) - .into_iter() .map(|x| { lcp[x] }) .min() .unwrap() @@ -79,7 +78,6 @@ fn compute_lz77( debug_assert_eq!( ret, (sa_position + 1..nsv_sa_position + 1) - .into_iter() .map(|x| { lcp[x] }) .min() .unwrap() diff --git a/src/bin/escape.rs b/src/bin/escape.rs index 5f744ec..89e7561 100644 --- a/src/bin/escape.rs +++ b/src/bin/escape.rs @@ -73,9 +73,19 @@ fn main() { let mut writer = io::stream_or_stdout(core::stringopt_stropt(&args.outfilename)); //@ sanity checks - assert_eq!(args.from_symbols.len(), args.to_symbols.len(), "The set of --from and --to symbols must be of equal size!"); - assert!(!args.from_symbols.contains(&args.escape_symbol), "The set of --from symbols must not contain the escape symbol!"); - assert!(!args.to_symbols.contains(&args.escape_symbol), "The set of --to symbols must not contain the escape symbol!"); + assert_eq!( + args.from_symbols.len(), + args.to_symbols.len(), + "The set of --from and --to symbols must be of equal size!" + ); + assert!( + !args.from_symbols.contains(&args.escape_symbol), + "The set of --from symbols must not contain the escape symbol!" + ); + assert!( + !args.to_symbols.contains(&args.escape_symbol), + "The set of --to symbols must not contain the escape symbol!" + ); assert!(!args .from_symbols .iter() diff --git a/src/bin/is_stringattractor.rs b/src/bin/is_stringattractor.rs index afb0748..aa4505b 100644 --- a/src/bin/is_stringattractor.rs +++ b/src/bin/is_stringattractor.rs @@ -106,8 +106,7 @@ fn lcp_intervals(text: &[u8], sa: &[i32], lcp: &[u32]) -> Vec { } let mut child_ptr: Option>> = None; // treat remaining nodes on `path` - while !path.is_empty() { - let node = path.pop().unwrap(); + while let Some(node) = path.pop() { node.borrow_mut().end = (n - 1) as u32; if let Some(child) = &child_ptr { let label = diff --git a/src/core.rs b/src/core.rs index 2a6b09a..bf1b358 100644 --- a/src/core.rs +++ b/src/core.rs @@ -11,7 +11,10 @@ pub fn bwt_from_text_by_sa(text: &Vec) -> Vec { assert_gt!(!text.len(), 0); let n = text.len(); let mut sa = vec![0; n]; - assert!(!text[..text.len() - 1].iter().any(|&x| x == 0), "the input text contains bytes equal to zero!"); + assert!( + !text[..text.len() - 1].iter().any(|&x| x == 0), + "the input text contains bytes equal to zero!" + ); cdivsufsort::sort_in_place(text, sa.as_mut_slice()); let mut bwt = vec![text[0]; n]; // let mut rsa = vec![0; n];