diff --git a/lib/oxttl/src/toolkit/parser.rs b/lib/oxttl/src/toolkit/parser.rs index 10965818..a02afec4 100644 --- a/lib/oxttl/src/toolkit/parser.rs +++ b/lib/oxttl/src/toolkit/parser.rs @@ -99,11 +99,10 @@ impl Parser { } } if self.lexer.is_end() { - if let Some(state) = self.state.take() { - state.recognize_end(&mut self.results, &mut self.errors) - } else { + let Some(state) = self.state.take() else { return None; - } + }; + state.recognize_end(&mut self.results, &mut self.errors) } else { return None; } diff --git a/lib/oxttl/src/trig.rs b/lib/oxttl/src/trig.rs index 692d6543..1860c56e 100644 --- a/lib/oxttl/src/trig.rs +++ b/lib/oxttl/src/trig.rs @@ -570,11 +570,9 @@ fn is_turtle_decimal(value: &str) -> bool { while value.first().map_or(false, u8::is_ascii_digit) { value = &value[1..]; } - if let Some(v) = value.strip_prefix(b".") { - value = v; - } else { + let Some(value) = value.strip_prefix(b".") else { return false; - } + }; !value.is_empty() && value.iter().all(u8::is_ascii_digit) } diff --git a/lib/sparesults/src/csv.rs b/lib/sparesults/src/csv.rs index 7d737e5b..759aea26 100644 --- a/lib/sparesults/src/csv.rs +++ b/lib/sparesults/src/csv.rs @@ -230,11 +230,9 @@ fn is_turtle_decimal(value: &str) -> bool { while value.first().map_or(false, u8::is_ascii_digit) { value = &value[1..]; } - if let Some(v) = value.strip_prefix(b".") { - value = v; - } else { + let Some(value) = value.strip_prefix(b".") else { return false; - } + }; !value.is_empty() && value.iter().all(u8::is_ascii_digit) } diff --git a/lib/src/storage/backend/fallback.rs b/lib/src/storage/backend/fallback.rs index 1c156111..6bdd5673 100644 --- a/lib/src/storage/backend/fallback.rs +++ b/lib/src/storage/backend/fallback.rs @@ -129,9 +129,7 @@ impl Reader { let data: Vec<_> = match &self.0 { InnerReader::Simple(reader) => { let trees = reader.read().unwrap(); - let tree = if let Some(tree) = trees.get(column_family) { - tree - } else { + let Some(tree) = trees.get(column_family) else { return Ok(Iter { iter: Vec::new().into_iter(), current: None, @@ -147,28 +145,25 @@ impl Reader { } } InnerReader::Transaction(reader) => { - if let Some(reader) = reader.upgrade() { - let trees = (*reader).borrow(); - let tree = if let Some(tree) = trees.get(column_family) { - tree - } else { - return Ok(Iter { - iter: Vec::new().into_iter(), - current: None, - }); - }; - if prefix.is_empty() { - tree.iter().map(|(k, v)| (k.clone(), v.clone())).collect() - } else { - tree.range(prefix.to_vec()..) - .take_while(|(k, _)| k.starts_with(prefix)) - .map(|(k, v)| (k.clone(), v.clone())) - .collect() - } - } else { + let Some(reader) = reader.upgrade() else { return Err(StorageError::Other( "The transaction is already ended".into(), )); + }; + let trees = (*reader).borrow(); + let Some(tree) = trees.get(column_family) else { + return Ok(Iter { + iter: Vec::new().into_iter(), + current: None, + }); + }; + if prefix.is_empty() { + tree.iter().map(|(k, v)| (k.clone(), v.clone())).collect() + } else { + tree.range(prefix.to_vec()..) + .take_while(|(k, _)| k.starts_with(prefix)) + .map(|(k, v)| (k.clone(), v.clone())) + .collect() } } }; diff --git a/lib/src/storage/backend/rocksdb.rs b/lib/src/storage/backend/rocksdb.rs index 81577551..0e9fe986 100644 --- a/lib/src/storage/backend/rocksdb.rs +++ b/lib/src/storage/backend/rocksdb.rs @@ -941,19 +941,18 @@ impl Reader { )) } InnerReader::Transaction(inner) => { - if let Some(inner) = inner.upgrade() { - ffi_result!(rocksdb_transaction_get_pinned_cf_with_status( - *inner, - self.options, - column_family.0, - key.as_ptr().cast(), - key.len() - )) - } else { - return Err(StorageError::Other( - "The transaction is already ended".into(), - )); - } + let Some(inner) = inner.upgrade() else { + return Err(StorageError::Other( + "The transaction is already ended".into(), + )); + }; + ffi_result!(rocksdb_transaction_get_pinned_cf_with_status( + *inner, + self.options, + column_family.0, + key.as_ptr().cast(), + key.len() + )) } InnerReader::PlainDb(inner) => { ffi_result!(rocksdb_get_pinned_cf_with_status( @@ -1022,13 +1021,12 @@ impl Reader { rocksdb_transactiondb_create_iterator_cf(inner.db.db, options, column_family.0) } InnerReader::Transaction(inner) => { - if let Some(inner) = inner.upgrade() { - rocksdb_transaction_create_iterator_cf(*inner, options, column_family.0) - } else { + let Some(inner) = inner.upgrade() else { return Err(StorageError::Other( "The transaction is already ended".into(), )); - } + }; + rocksdb_transaction_create_iterator_cf(*inner, options, column_family.0) } InnerReader::PlainDb(inner) => { rocksdb_create_iterator_cf(inner.db, options, column_family.0) diff --git a/testsuite/src/manifest.rs b/testsuite/src/manifest.rs index 7563b5c3..f854b95e 100644 --- a/testsuite/src/manifest.rs +++ b/testsuite/src/manifest.rs @@ -84,9 +84,7 @@ impl TestManifest { fn next_test(&mut self) -> Result> { loop { - let test_node = if let Some(test_node) = self.tests_to_do.pop_front() { - test_node - } else { + let Some(test_node) = self.tests_to_do.pop_front() else { return Ok(None); }; let test_node = if let Term::NamedNode(test_node) = test_node { @@ -273,9 +271,7 @@ impl TestManifest { } fn load_next_manifest(&mut self) -> Result> { - let url = if let Some(url) = self.manifests_to_do.pop_front() { - url - } else { + let Some(url) = self.manifests_to_do.pop_front() else { return Ok(None); }; self.graph.clear();