diff --git a/cli/build.rs b/cli/build.rs index 117b1f6d..d59980a5 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -65,10 +65,7 @@ fn web_playground_files_present() -> bool { fn read_git_sha() -> Option { let crate_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); - if !crate_path - .parent() - .map_or(false, |p| p.join(".git").exists()) - { + if !crate_path.parent().is_some_and(|p| p.join(".git").exists()) { return None; } diff --git a/cli/generate/src/build_tables/mod.rs b/cli/generate/src/build_tables/mod.rs index 1e3b65b3..3d7ee4d7 100644 --- a/cli/generate/src/build_tables/mod.rs +++ b/cli/generate/src/build_tables/mod.rs @@ -208,7 +208,7 @@ fn populate_used_symbols( // ensure that a subtree's symbol can be successfully reassigned to the word token // without having to move the subtree to the heap. // See https://github.com/tree-sitter/tree-sitter/issues/258 - if syntax_grammar.word_token.map_or(false, |t| t.index == i) { + if syntax_grammar.word_token.is_some_and(|t| t.index == i) { parse_table.symbols.insert(1, Symbol::terminal(i)); } else { parse_table.symbols.push(Symbol::terminal(i)); diff --git a/cli/generate/src/nfa.rs b/cli/generate/src/nfa.rs index 1b6f8804..3d14b513 100644 --- a/cli/generate/src/nfa.rs +++ b/cli/generate/src/nfa.rs @@ -363,9 +363,9 @@ impl CharacterSet { }) { Ok(ix) | Err(ix) => ix, }; - self.ranges.get(ix).map_or(false, |range| { - range.start <= seek_range.start && range.end >= seek_range.end - }) + self.ranges + .get(ix) + .is_some_and(|range| range.start <= seek_range.start && range.end >= seek_range.end) } pub fn contains(&self, c: char) -> bool { diff --git a/cli/generate/src/node_types.rs b/cli/generate/src/node_types.rs index f87a3d4b..debd8ae1 100644 --- a/cli/generate/src/node_types.rs +++ b/cli/generate/src/node_types.rs @@ -574,7 +574,7 @@ pub fn generate_node_types_json( if node_type_json .children .as_ref() - .map_or(false, |c| c.types.is_empty()) + .is_some_and(|c| c.types.is_empty()) { node_type_json.children = None; } diff --git a/cli/generate/src/parse_grammar.rs b/cli/generate/src/parse_grammar.rs index 2934d36b..fedb6382 100644 --- a/cli/generate/src/parse_grammar.rs +++ b/cli/generate/src/parse_grammar.rs @@ -202,7 +202,7 @@ pub(crate) fn parse_grammar(input: &str) -> Result { (&extra_symbols, &external_tokens), name, &mut in_progress, - ) && grammar_json.word.as_ref().map_or(true, |w| w != name) + ) && grammar_json.word.as_ref().is_some_and(|w| w != name) { grammar_json.conflicts.retain(|r| !r.contains(name)); grammar_json.supertypes.retain(|r| r != name); diff --git a/cli/loader/src/lib.rs b/cli/loader/src/lib.rs index c58add8d..4e3effed 100644 --- a/cli/loader/src/lib.rs +++ b/cli/loader/src/lib.rs @@ -481,7 +481,7 @@ impl Loader { scope: &str, ) -> Result> { for configuration in &self.language_configurations { - if configuration.scope.as_ref().map_or(false, |s| s == scope) { + if configuration.scope.as_ref().is_some_and(|s| s == scope) { let language = self.language_for_id(configuration.language_id)?; return Ok(Some((language, configuration))); } @@ -977,13 +977,13 @@ impl Loader { } else if Command::new("docker") .arg("info") .output() - .map_or(false, |out| out.status.success()) + .is_ok_and(|out| out.status.success()) { EmccSource::Docker } else if Command::new("podman") .arg("--version") .output() - .map_or(false, |out| out.status.success()) + .is_ok_and(|out| out.status.success()) { EmccSource::Podman } else { diff --git a/cli/src/highlight.rs b/cli/src/highlight.rs index 41e07850..60f73d49 100644 --- a/cli/src/highlight.rs +++ b/cli/src/highlight.rs @@ -307,9 +307,8 @@ fn write_color(buffer: &mut String, color: Color) { } fn terminal_supports_truecolor() -> bool { - std::env::var("COLORTERM").map_or(false, |truecolor| { - truecolor == "truecolor" || truecolor == "24bit" - }) + std::env::var("COLORTERM") + .is_ok_and(|truecolor| truecolor == "truecolor" || truecolor == "24bit") } fn closest_xterm_color(red: u8, green: u8, blue: u8) -> Color { diff --git a/cli/src/tests/helpers/fixtures.rs b/cli/src/tests/helpers/fixtures.rs index 766a86eb..943d7cf3 100644 --- a/cli/src/tests/helpers/fixtures.rs +++ b/cli/src/tests/helpers/fixtures.rs @@ -84,7 +84,7 @@ pub fn get_test_language(name: &str, parser_code: &str, path: Option<&Path>) -> fs::create_dir_all(&src_dir).unwrap(); let parser_path = src_dir.join("parser.c"); - if !fs::read_to_string(&parser_path).map_or(false, |content| content == parser_code) { + if !fs::read_to_string(&parser_path).is_ok_and(|content| content == parser_code) { fs::write(&parser_path, parser_code).unwrap(); } @@ -93,8 +93,7 @@ pub fn get_test_language(name: &str, parser_code: &str, path: Option<&Path>) -> if scanner_path.exists() { let scanner_code = fs::read_to_string(&scanner_path).unwrap(); let scanner_copy_path = src_dir.join("scanner.c"); - if !fs::read_to_string(&scanner_copy_path) - .map_or(false, |content| content == scanner_code) + if !fs::read_to_string(&scanner_copy_path).is_ok_and(|content| content == scanner_code) { fs::write(&scanner_copy_path, scanner_code).unwrap(); } diff --git a/tags/src/lib.rs b/tags/src/lib.rs index 6383786b..00debaaf 100644 --- a/tags/src/lib.rs +++ b/tags/src/lib.rs @@ -199,7 +199,7 @@ impl TagsConfiguration { && property .value .as_ref() - .map_or(false, |v| v.as_ref() == "false") + .is_some_and(|v| v.as_ref() == "false") { info.local_scope_inherits = false; } diff --git a/xtask/src/build_wasm.rs b/xtask/src/build_wasm.rs index 5ff63a22..ee3c7d5b 100644 --- a/xtask/src/build_wasm.rs +++ b/xtask/src/build_wasm.rs @@ -35,13 +35,13 @@ pub fn run_wasm(args: &BuildWasm) -> Result<()> { } else if Command::new("docker") .arg("info") .output() - .map_or(false, |out| out.status.success()) + .is_ok_and(|out| out.status.success()) { EmccSource::Docker } else if Command::new("podman") .arg("--version") .output() - .map_or(false, |out| out.status.success()) + .is_ok_and(|out| out.status.success()) { EmccSource::Podman } else {