summaryrefslogtreecommitdiff
path: root/crates/typst-syntax
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-02-28 15:24:50 +0100
committerGitHub <noreply@github.com>2024-02-28 14:24:50 +0000
commit8d63b0479c8b74a756a9e9b34d97f821f280fd22 (patch)
tree30cc34e366948d9ea461a1ad35f80bb5c89e10ab /crates/typst-syntax
parent9d8df00ffb587f1e6062ae471d3da3b1ac61ba9e (diff)
Make use of `is_some_and` where applicable (#3523)
Diffstat (limited to 'crates/typst-syntax')
-rw-r--r--crates/typst-syntax/src/ast.rs4
-rw-r--r--crates/typst-syntax/src/lexer.rs6
-rw-r--r--crates/typst-syntax/src/parser.rs2
3 files changed, 6 insertions, 6 deletions
diff --git a/crates/typst-syntax/src/ast.rs b/crates/typst-syntax/src/ast.rs
index df9cef0c..26a26160 100644
--- a/crates/typst-syntax/src/ast.rs
+++ b/crates/typst-syntax/src/ast.rs
@@ -601,12 +601,12 @@ impl<'a> Raw<'a> {
let is_whitespace = |line: &&str| line.chars().all(char::is_whitespace);
// Trims a sequence of whitespace followed by a newline at the start.
- if lines.first().map_or(false, is_whitespace) {
+ if lines.first().is_some_and(is_whitespace) {
lines.remove(0);
}
// Trims a newline followed by a sequence of whitespace at the end.
- if lines.last().map_or(false, is_whitespace) {
+ if lines.last().is_some_and(is_whitespace) {
lines.pop();
}
}
diff --git a/crates/typst-syntax/src/lexer.rs b/crates/typst-syntax/src/lexer.rs
index cd1998a6..300a8353 100644
--- a/crates/typst-syntax/src/lexer.rs
+++ b/crates/typst-syntax/src/lexer.rs
@@ -341,7 +341,7 @@ impl Lexer<'_> {
fn in_word(&self) -> bool {
let wordy = |c: Option<char>| {
- c.map_or(false, |c| {
+ c.is_some_and(|c| {
c.is_alphanumeric()
&& !matches!(
c.script(),
@@ -538,7 +538,7 @@ impl Lexer<'_> {
// Make sure not to confuse a range for the decimal separator.
if c != '.'
&& !self.s.at("..")
- && !self.s.scout(1).map_or(false, is_id_start)
+ && !self.s.scout(1).is_some_and(is_id_start)
&& self.s.eat_if('.')
&& base == 10
{
@@ -740,7 +740,7 @@ pub fn is_ident(string: &str) -> bool {
let mut chars = string.chars();
chars
.next()
- .map_or(false, |c| is_id_start(c) && chars.all(is_id_continue))
+ .is_some_and(|c| is_id_start(c) && chars.all(is_id_continue))
}
/// Whether a character can start an identifier.
diff --git a/crates/typst-syntax/src/parser.rs b/crates/typst-syntax/src/parser.rs
index 0a740b62..f4bb19e1 100644
--- a/crates/typst-syntax/src/parser.rs
+++ b/crates/typst-syntax/src/parser.rs
@@ -1709,7 +1709,7 @@ impl<'s> Parser<'s> {
fn unskip(&mut self) {
if self.lexer.mode() != LexMode::Markup && self.prev_end != self.current_start {
- while self.nodes.last().map_or(false, |last| last.kind().is_trivia()) {
+ while self.nodes.last().is_some_and(|last| last.kind().is_trivia()) {
self.nodes.pop();
}