Skip to content

Commit 5bf1e81

Browse files
committed
Idiom cleanup to prepare for Rust 1.84
Clippy requires .map_or(false, ...) change to .is_some_and(...). Change-Id: I7d62bb4c2306b7e51455369339a64d4867344dd8 Reviewed-on: https://gerrit.readyset.name/c/readyset/+/8451 Tested-by: Buildkite CI Reviewed-by: Jason Brown <[email protected]>
1 parent 94a365d commit 5bf1e81

File tree

11 files changed

+35
-36
lines changed

11 files changed

+35
-36
lines changed

dataflow-state/src/memory_state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,11 +1213,11 @@ mod tests {
12131213
// Make sure we have a strict index with this tag, and then make sure that
12141214
// the hole hasn't already been filled, since we would never trigger a
12151215
// replay to a filled hole:
1216-
self.strict_indexes.get(tag).map_or(false, |index| {
1216+
self.strict_indexes.get(tag).is_some_and(|index| {
12171217
!self
12181218
.filled_holes
12191219
.get(index)
1220-
.map_or(false, |filled| filled.contains(key))
1220+
.is_some_and(|filled| filled.contains(key))
12211221
})
12221222
}
12231223
Operation::DeleteRow(row) => self.rows.contains(row),

mysql-srv/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ impl<B: MySqlShim<W> + Send, R: AsyncRead + Unpin, W: AsyncWrite + Unpin + Send>
562562
|| self
563563
.shim
564564
.password_for_username(&username)
565-
.map_or(false, |password| {
565+
.is_some_and(|password| {
566566
let expected = hash_password(&password, &auth_data);
567567
let actual = handshake_password.as_slice();
568568
trace!(?expected, ?actual);
@@ -641,7 +641,7 @@ impl<B: MySqlShim<W> + Send, R: AsyncRead + Unpin, W: AsyncWrite + Unpin + Send>
641641
}
642642
let plain_password = self.shim.password_for_username(&username);
643643
let auth_success = !self.shim.require_authentication()
644-
|| plain_password.as_ref().map_or(false, |password| {
644+
|| plain_password.as_ref().is_some_and(|password| {
645645
let expected = hash_password(password, &self.auth_data);
646646
let actual = authpassword.as_slice();
647647
trace!(?expected, ?actual);

reader-map/src/read.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ where
234234
K: Borrow<Q>,
235235
Q: Ord + Hash + ?Sized,
236236
{
237-
self.enter().map_or(false, |x| x.contains_key(key))
237+
self.enter().is_ok_and(|x| x.contains_key(key))
238238
}
239239

240240
/// Read all values in the map, and transform them into a new collection.

readyset-dataflow/src/domain/replay_paths.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl ReplayPaths {
233233
{
234234
self.generated_columns
235235
.get(node)
236-
.map_or(false, |by_cols| by_cols.contains_key(columns))
236+
.is_some_and(|by_cols| by_cols.contains_key(columns))
237237
}
238238

239239
/// Return a list of all replay paths that pass through `from` into `node`, represented as the

readyset-dataflow/src/node/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,12 @@ impl Node {
318318
/// Returns true if this operator requires a full materialization
319319
pub fn requires_full_materialization(&self) -> bool {
320320
self.as_internal()
321-
.map_or(false, Ingredient::requires_full_materialization)
321+
.is_some_and(Ingredient::requires_full_materialization)
322322
}
323323

324324
pub fn can_query_through(&self) -> bool {
325325
self.as_internal()
326-
.map_or(false, Ingredient::can_query_through)
326+
.is_some_and(Ingredient::can_query_through)
327327
}
328328

329329
pub fn is_join(&self) -> ReadySetResult<bool> {
@@ -669,7 +669,7 @@ impl Node {
669669
}
670670

671671
pub fn is_reader_for(&self, ni: NodeIndex) -> bool {
672-
self.as_reader().map_or(false, |r| r.is_for() == ni)
672+
self.as_reader().is_some_and(|r| r.is_for() == ni)
673673
}
674674

675675
pub fn is_ingress(&self) -> bool {

readyset-logictest/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ impl Value {
682682
match other.typ() {
683683
None => *self == Value::Null,
684684
Some(typ) => Self::from_mysql_value_with_type(mysql_async::Value::from(self), &typ)
685-
.map_or(false, |v| v == *other),
685+
.is_ok_and(|v| v == *other),
686686
}
687687
}
688688
}

readyset-mysql/tests/vertical.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ where
293293
if deps.iter().all(|dep| {
294294
self.rows
295295
.get(dep)
296-
.map_or(false, |dep_rows| !dep_rows.is_empty())
296+
.is_some_and(|dep_rows| !dep_rows.is_empty())
297297
}) {
298298
Some(*table)
299299
} else {
@@ -367,7 +367,7 @@ where
367367
| Operation::Delete { table, row } => self
368368
.rows
369369
.get(table)
370-
.map_or(false, |table_rows| table_rows.contains(row)),
370+
.is_some_and(|table_rows| table_rows.contains(row)),
371371
// Can always insert any row or query any key or request an eviction and we shouldn't
372372
// error out
373373
Operation::Insert { .. } | Operation::Query { .. } | Operation::Evict { .. } => true,

readyset-server/src/controller/migrate/materialization/plan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<'a> Plan<'a> {
7878
dmp: &'a mut DomainMigrationPlan,
7979
) -> Plan<'a> {
8080
let partial = m.partial.contains(&node);
81-
let has_paths = m.paths.get(&node).map_or(false, |paths| !paths.is_empty());
81+
let has_paths = m.paths.get(&node).is_some_and(|paths| !paths.is_empty());
8282
Plan {
8383
m,
8484
graph,

readyset-server/src/controller/state.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,11 +1012,9 @@ impl DfState {
10121012

10131013
/// Have all domain replicas been placed onto workers in the cluster?
10141014
pub(super) fn all_replicas_placed(&self) -> bool {
1015-
self.domain_nodes.keys().all(|d| {
1016-
self.domains
1017-
.get(d)
1018-
.map_or(false, |h| h.all_replicas_placed())
1019-
})
1015+
self.domain_nodes
1016+
.keys()
1017+
.all(|d| self.domains.get(d).is_some_and(|h| h.all_replicas_placed()))
10201018
}
10211019

10221020
/// Returns a map of nodes for domains which have not yet been placed onto a worker

replicators/tests/ddl_vertical_mysql.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,8 @@ impl ModelState for DDLModelState {
569569
// row that we're trying to write:
570570
self.pkeys
571571
.get(table)
572-
.map_or(false, |table_keys| !table_keys.contains(pkey))
573-
&& self.tables.get(table).map_or(false, |table_cols| {
572+
.is_some_and(|table_keys| !table_keys.contains(pkey))
573+
&& self.tables.get(table).is_some_and(|table_cols| {
574574
// Must compare lengths before zipping and comparing individual types
575575
// because zip will drop elements if the Vec lengths don't match up:
576576
table_cols.len() == col_types.len()
@@ -584,20 +584,20 @@ impl ModelState for DDLModelState {
584584
Operation::DeleteRow(table, key) => self
585585
.pkeys
586586
.get(table)
587-
.map_or(false, |table_keys| table_keys.contains(key)),
587+
.is_some_and(|table_keys| table_keys.contains(key)),
588588
Operation::AddColumn(table, column_spec) => self
589589
.tables
590590
.get(table)
591-
.map_or(false, |t| t.iter().all(|cs| cs.name != *column_spec.name)),
591+
.is_some_and(|t| t.iter().all(|cs| cs.name != *column_spec.name)),
592592
Operation::DropColumn(table, col_name) => self
593593
.tables
594594
.get(table)
595-
.map_or(false, |t| t.iter().any(|cs| cs.name == *col_name)),
595+
.is_some_and(|t| t.iter().any(|cs| cs.name == *col_name)),
596596
Operation::AlterColumnName {
597597
table,
598598
col_name,
599599
new_name,
600-
} => self.tables.get(table).map_or(false, |t| {
600+
} => self.tables.get(table).is_some_and(|t| {
601601
t.iter().any(|cs| cs.name == *col_name) && t.iter().all(|cs| cs.name != *new_name)
602602
}),
603603
Operation::CreateSimpleView { name, table_source } => {

0 commit comments

Comments
 (0)