diff --git a/rslib/proto_gen/src/lib.rs b/rslib/proto_gen/src/lib.rs index 8e4656632..bbb40d122 100644 --- a/rslib/proto_gen/src/lib.rs +++ b/rslib/proto_gen/src/lib.rs @@ -236,7 +236,7 @@ where E: Fn(&Utf8Path, &str) -> bool, { static MESSAGE_OR_ENUM_RE: Lazy = - Lazy::new(|| Regex::new(r#"pub (struct|enum) ([[:alnum:]]+?)\s"#).unwrap()); + Lazy::new(|| Regex::new(r"pub (struct|enum) ([[:alnum:]]+?)\s").unwrap()); let contents = read_to_string(path)?; let contents = MESSAGE_OR_ENUM_RE.replace_all(&contents, |caps: &Captures| { let is_enum = caps.get(1).unwrap().as_str() == "enum"; diff --git a/rslib/src/cloze.rs b/rslib/src/cloze.rs index c00447487..a0a0edd8b 100644 --- a/rslib/src/cloze.rs +++ b/rslib/src/cloze.rs @@ -22,11 +22,11 @@ use crate::text::strip_html_preserving_entities; lazy_static! { static ref MATHJAX: Regex = Regex::new( - r#"(?xsi) + r"(?xsi) (\\[(\[]) # 1 = mathjax opening tag (.*?) # 2 = inner content (\\[])]) # 3 = mathjax closing tag - "# + " ) .unwrap(); } diff --git a/rslib/src/deckconfig/mod.rs b/rslib/src/deckconfig/mod.rs index ba2f10eb0..d1515d61b 100644 --- a/rslib/src/deckconfig/mod.rs +++ b/rslib/src/deckconfig/mod.rs @@ -135,12 +135,12 @@ impl Collection { &mut self, config: &mut DeckConfig, ) -> Result<()> { - let usn = Some(self.usn()?); + let usn = self.usn()?; if config.id.0 == 0 { - self.add_deck_config_inner(config, usn) + self.add_deck_config_inner(config, Some(usn)) } else { - config.set_modified(usn.unwrap()); + config.set_modified(usn); self.storage .add_or_update_deck_config_with_existing_id(config) } diff --git a/rslib/src/image_occlusion/imagedata.rs b/rslib/src/image_occlusion/imagedata.rs index c2ca96dac..a2c525e69 100644 --- a/rslib/src/image_occlusion/imagedata.rs +++ b/rslib/src/image_occlusion/imagedata.rs @@ -141,7 +141,7 @@ impl Collection { fn is_image_file(&mut self, path: &PathBuf) -> Result { let file_path = Path::new(&path); - let supported_extensions = vec![ + let supported_extensions = [ "jpg", "jpeg", "png", "tif", "tiff", "gif", "svg", "webp", "ico", ]; diff --git a/rslib/src/import_export/package/mod.rs b/rslib/src/import_export/package/mod.rs index 4e7cfc0e2..823cf0633 100644 --- a/rslib/src/import_export/package/mod.rs +++ b/rslib/src/import_export/package/mod.rs @@ -6,13 +6,13 @@ mod colpkg; mod media; mod meta; -pub(self) use anki_proto::import_export::media_entries::MediaEntry; -pub(self) use anki_proto::import_export::MediaEntries; +use anki_proto::import_export::media_entries::MediaEntry; +use anki_proto::import_export::MediaEntries; pub(crate) use apkg::NoteMeta; pub(crate) use colpkg::export::export_colpkg_from_data; pub use colpkg::import::import_colpkg; pub use media::MediaIter; pub use media::MediaIterEntry; pub use media::MediaIterError; -pub(self) use meta::Meta; -pub(self) use meta::Version; +use meta::Meta; +use meta::Version; diff --git a/rslib/src/import_export/text/csv/export.rs b/rslib/src/import_export/text/csv/export.rs index ff7714b9c..0f1e712e8 100644 --- a/rslib/src/import_export/text/csv/export.rs +++ b/rslib/src/import_export/text/csv/export.rs @@ -198,7 +198,7 @@ impl NoteContext { .max() .unwrap_or_default(); let deck_ids = col.storage.all_decks_of_search_notes()?; - let deck_names = HashMap::from_iter(col.storage.get_all_deck_names()?.into_iter()); + let deck_names = HashMap::from_iter(col.storage.get_all_deck_names()?); Ok(Self { with_html: request.with_html, @@ -236,10 +236,10 @@ impl NoteContext { self.with_guid .then(|| Cow::from(note.guid.as_bytes())) .into_iter() - .chain(self.notetype_name(note).into_iter()) - .chain(self.deck_name(note).into_iter()) + .chain(self.notetype_name(note)) + .chain(self.deck_name(note)) .chain(self.note_fields(note)) - .chain(self.tags(note).into_iter()) + .chain(self.tags(note)) } fn notetype_name(&self, note: &Note) -> Option> { diff --git a/rslib/src/import_export/text/import.rs b/rslib/src/import_export/text/import.rs index 11c02349c..bf598dc4c 100644 --- a/rslib/src/import_export/text/import.rs +++ b/rslib/src/import_export/text/import.rs @@ -558,7 +558,7 @@ impl ForeignNote { note.tags.extend(extra_tags.into_iter().cloned()); note.fields_mut() .iter_mut() - .zip(self.fields.into_iter()) + .zip(self.fields) .for_each(|(field, new)| { if let Some(s) = new { *field = s; diff --git a/rslib/src/latex.rs b/rslib/src/latex.rs index 2217bc72d..f6a03c107 100644 --- a/rslib/src/latex.rs +++ b/rslib/src/latex.rs @@ -13,13 +13,13 @@ use crate::text::strip_html; lazy_static! { pub(crate) static ref LATEX: Regex = Regex::new( - r#"(?xsi) + r"(?xsi) \[latex\](.+?)\[/latex\] # 1 - standard latex | \[\$\](.+?)\[/\$\] # 2 - inline math | \[\$\$\](.+?)\[/\$\$\] # 3 - math environment - "# + " ) .unwrap(); static ref LATEX_NEWLINES: Regex = Regex::new( diff --git a/rslib/src/media/files.rs b/rslib/src/media/files.rs index 9a32629ac..d60e70791 100644 --- a/rslib/src/media/files.rs +++ b/rslib/src/media/files.rs @@ -29,7 +29,7 @@ use crate::sync::media::MAX_MEDIA_FILENAME_LENGTH; lazy_static! { static ref WINDOWS_DEVICE_NAME: Regex = Regex::new( - r#"(?xi) + r"(?xi) # starting with one of the following names ^ ( @@ -39,17 +39,17 @@ lazy_static! { ( \. | $ ) - "# + " ) .unwrap(); static ref WINDOWS_TRAILING_CHAR: Regex = Regex::new( - r#"(?x) + r"(?x) # filenames can't end with a space or period ( \x20 | \. ) $ - "# + " ) .unwrap(); pub(crate) static ref NONSYNCABLE_FILENAME: Regex = Regex::new( diff --git a/rslib/src/notetype/notetypechange.rs b/rslib/src/notetype/notetypechange.rs index 9460ab682..5bc7e43f6 100644 --- a/rslib/src/notetype/notetypechange.rs +++ b/rslib/src/notetype/notetypechange.rs @@ -164,7 +164,7 @@ fn default_template_map( new_templates .iter_mut() .filter(|o| o.is_none()) - .zip(remaining_templates.into_iter()) + .zip(remaining_templates) .for_each(|(template, old_idx)| *template = Some(*old_idx)); Some(new_templates) @@ -202,7 +202,7 @@ fn default_field_map(current_notetype: &Notetype, new_notetype: &Notetype) -> Ve new_fields .iter_mut() .filter(|o| o.is_none()) - .zip(remaining_fields.into_iter()) + .zip(remaining_fields) .for_each(|(field, old_idx)| *field = Some(*old_idx)); new_fields diff --git a/rslib/src/scheduler/reviews.rs b/rslib/src/scheduler/reviews.rs index 4e6d1b5a1..c853a2942 100644 --- a/rslib/src/scheduler/reviews.rs +++ b/rslib/src/scheduler/reviews.rs @@ -67,7 +67,7 @@ pub struct DueDateSpecifier { pub fn parse_due_date_str(s: &str) -> Result { lazy_static! { static ref RE: Regex = Regex::new( - r#"(?x)^ + r"(?x)^ # a number (?P\d+) # an optional hyphen and another number @@ -78,7 +78,7 @@ pub fn parse_due_date_str(s: &str) -> Result { # optional exclamation mark (?P!)? $ - "# + " ) .unwrap(); } diff --git a/rslib/src/search/parser.rs b/rslib/src/search/parser.rs index 55ab6b5fc..8c80da2f3 100644 --- a/rslib/src/search/parser.rs +++ b/rslib/src/search/parser.rs @@ -824,8 +824,8 @@ mod test { // parser doesn't unescape unescape \*_ assert_eq!( - parse(r#"\\\*\_"#)?, - vec![Search(UnqualifiedText(r#"\\\*\_"#.into())),] + parse(r"\\\*\_")?, + vec![Search(UnqualifiedText(r"\\\*\_".into())),] ); // escaping parentheses is optional (only) inside quotes diff --git a/rslib/src/search/sqlwriter.rs b/rslib/src/search/sqlwriter.rs index c14429921..89463e991 100644 --- a/rslib/src/search/sqlwriter.rs +++ b/rslib/src/search/sqlwriter.rs @@ -987,7 +987,7 @@ mod test { ); assert_eq!(s(ctx, "te%st").1, vec![r"%te\%st%".to_string()]); // user should be able to escape wildcards - assert_eq!(s(ctx, r#"te\*s\_t"#).1, vec!["%te*s\\_t%".to_string()]); + assert_eq!(s(ctx, r"te\*s\_t").1, vec!["%te*s\\_t%".to_string()]); // field search assert_eq!( @@ -1255,6 +1255,7 @@ c.odue != 0 then c.odue else c.due end) != {days}) or (c.queue in (1,4) and ); } + #[allow(clippy::single_range_in_vec_init)] #[test] fn ranges() { assert_eq!([1, 2, 3].collect_ranges(), [1..4]); diff --git a/rslib/src/template.rs b/rslib/src/template.rs index 8a4d006a2..ec66d1f92 100644 --- a/rslib/src/template.rs +++ b/rslib/src/template.rs @@ -550,13 +550,13 @@ fn append_str_to_nodes(nodes: &mut Vec, text: &str) { pub(crate) fn field_is_empty(text: &str) -> bool { lazy_static! { static ref RE: Regex = Regex::new( - r#"(?xsi) + r"(?xsi) ^(?: [[:space:]] | )*$ - "# + " ) .unwrap(); } @@ -986,7 +986,7 @@ mod test { #[test] fn requirements() { - let field_map: FieldMap = vec!["a", "b", "c"] + let field_map: FieldMap = ["a", "b", "c"] .iter() .enumerate() .map(|(a, b)| (*b, a as u16)) diff --git a/rslib/src/template_filters.rs b/rslib/src/template_filters.rs index e762a8a22..b6408d965 100644 --- a/rslib/src/template_filters.rs +++ b/rslib/src/template_filters.rs @@ -218,6 +218,7 @@ mod test { ); } + #[allow(clippy::needless_raw_string_hashes)] #[test] fn hint() { assert_eq!( diff --git a/rslib/src/text.rs b/rslib/src/text.rs index 9c1f7a2fc..7d78b22c4 100644 --- a/rslib/src/text.rs +++ b/rslib/src/text.rs @@ -133,16 +133,16 @@ lazy_static! { // videos are also in sound tags static ref AV_TAGS: Regex = Regex::new( - r#"(?xs) + r"(?xs) \[sound:(.+?)\] # 1 - the filename in a sound tag | \[anki:tts\] \[(.*?)\] # 2 - arguments to tts call (.*?) # 3 - field text \[/anki:tts\] - "#).unwrap(); + ").unwrap(); - static ref PERSISTENT_HTML_SPACERS: Regex = Regex::new(r#"(?i)|
|\n"#).unwrap(); + static ref PERSISTENT_HTML_SPACERS: Regex = Regex::new(r"(?i)|
|\n").unwrap(); static ref TYPE_TAG: Regex = Regex::new(r"\[\[type:[^]]+\]\]").unwrap(); pub(crate) static ref SOUND_TAG: Regex = Regex::new(r"\[sound:([^]]+)\]").unwrap(); @@ -391,11 +391,11 @@ pub(crate) fn is_glob(txt: &str) -> bool { // even number of \s followed by a wildcard lazy_static! { static ref RE: Regex = Regex::new( - r#"(?x) + r"(?x) (?:^|[^\\]) # not a backslash (?:\\\\)* # even number of backslashes [*_] # wildcard - "# + " ) .unwrap(); } diff --git a/rslib/src/typeanswer.rs b/rslib/src/typeanswer.rs index 1a95258b6..3da3a1c42 100644 --- a/rslib/src/typeanswer.rs +++ b/rslib/src/typeanswer.rs @@ -16,7 +16,7 @@ use crate::text::strip_html; lazy_static! { static ref LINEBREAKS: Regex = Regex::new( - r#"(?six) + r"(?six) ( \n | @@ -24,7 +24,7 @@ lazy_static! { | )+ - "# + " ) .unwrap(); }