diff --git a/crates/cli/src/modules/mod.rs b/crates/cli/src/modules/mod.rs index a9d5eb5c4..d5085fde2 100644 --- a/crates/cli/src/modules/mod.rs +++ b/crates/cli/src/modules/mod.rs @@ -238,7 +238,7 @@ pub async fn name_to_id(client: &Client, name: &str) -> String { pub fn is_localhost(url: &str) -> bool { url.split_once("://") .map(|(_, url)| url.split_once('/').map_or(url, |(host, _)| host)) - .map_or(false, |host| { + .is_some_and(|host| { let host = host.rsplit_once(':').map_or(host, |(host, _)| host); host == "localhost" || host == "127.0.0.1" || host == "[::1]" }) diff --git a/crates/common/src/auth/oauth/token.rs b/crates/common/src/auth/oauth/token.rs index 410487ea4..f6abd5d6c 100644 --- a/crates/common/src/auth/oauth/token.rs +++ b/crates/common/src/auth/oauth/token.rs @@ -149,7 +149,7 @@ impl Server { } // Validate grant type - if expected_grant_type.map_or(false, |g| g != grant_type) { + if expected_grant_type.is_some_and(|g| g != grant_type) { return Err(trc::AuthEvent::Error .into_err() .details("Invalid grant type")); diff --git a/crates/common/src/auth/sasl.rs b/crates/common/src/auth/sasl.rs index 92ba84b65..2c0d8f1f1 100644 --- a/crates/common/src/auth/sasl.rs +++ b/crates/common/src/auth/sasl.rs @@ -73,7 +73,7 @@ fn extract_oauth_bearer(bytes: &[u8]) -> Option<&str> { if is_separator || pos == eof { if bytes .get(start_pos..start_pos + 12) - .map_or(false, |s| s.eq_ignore_ascii_case(b"auth=Bearer ")) + .is_some_and(|s| s.eq_ignore_ascii_case(b"auth=Bearer ")) { return bytes .get(start_pos + 12..if is_separator { pos } else { bytes.len() }) diff --git a/crates/common/src/config/smtp/queue.rs b/crates/common/src/config/smtp/queue.rs index 34257bf00..31e0e8450 100644 --- a/crates/common/src/config/smtp/queue.rs +++ b/crates/common/src/config/smtp/queue.rs @@ -516,11 +516,11 @@ fn parse_queue_quota_item(config: &mut Config, prefix: impl AsKey, id: &str) -> keys, size: config .property::>((prefix.as_str(), "size")) - .filter(|&v| v.as_ref().map_or(false, |v| *v > 0)) + .filter(|&v| v.as_ref().is_some_and(|v| *v > 0)) .unwrap_or_default(), messages: config .property::>((prefix.as_str(), "messages")) - .filter(|&v| v.as_ref().map_or(false, |v| *v > 0)) + .filter(|&v| v.as_ref().is_some_and(|v| *v > 0)) .unwrap_or_default(), }; diff --git a/crates/common/src/config/smtp/throttle.rs b/crates/common/src/config/smtp/throttle.rs index a8b9c5aae..e8e11e224 100644 --- a/crates/common/src/config/smtp/throttle.rs +++ b/crates/common/src/config/smtp/throttle.rs @@ -83,11 +83,11 @@ fn parse_throttle_item( keys, concurrency: config .property::>((prefix.as_str(), "concurrency")) - .filter(|&v| v.as_ref().map_or(false, |v| *v > 0)) + .filter(|&v| v.as_ref().is_some_and(|v| *v > 0)) .unwrap_or_default(), rate: config .property::>((prefix.as_str(), "rate")) - .filter(|v| v.as_ref().map_or(false, |r| r.requests > 0)) + .filter(|v| v.as_ref().is_some_and(|r| r.requests > 0)) .unwrap_or_default(), }; diff --git a/crates/common/src/enterprise/mod.rs b/crates/common/src/enterprise/mod.rs index 315cc1801..5eec0f98b 100644 --- a/crates/common/src/enterprise/mod.rs +++ b/crates/common/src/enterprise/mod.rs @@ -108,7 +108,7 @@ impl Core { pub fn is_enterprise_edition(&self) -> bool { self.enterprise .as_ref() - .map_or(false, |e| !e.license.is_expired()) + .is_some_and(|e| !e.license.is_expired()) } } diff --git a/crates/common/src/expr/eval.rs b/crates/common/src/expr/eval.rs index 8b9b50631..79f63926b 100644 --- a/crates/common/src/expr/eval.rs +++ b/crates/common/src/expr/eval.rs @@ -145,7 +145,7 @@ struct EvalContext<'x, 'y, V: ResolveVariable, T, C> { session_id: u64, } -impl<'x, 'y, V: ResolveVariable> EvalContext<'x, 'y, V, IfBlock, Vec> { +impl<'x, V: ResolveVariable> EvalContext<'x, '_, V, IfBlock, Vec> { async fn eval(&mut self) -> trc::Result> { for if_then in &self.expr.if_then { if (EvalContext { @@ -183,7 +183,7 @@ impl<'x, 'y, V: ResolveVariable> EvalContext<'x, 'y, V, IfBlock, Vec> { } } -impl<'x, 'y, V: ResolveVariable> EvalContext<'x, 'y, V, Expression, &mut Vec> { +impl<'x, V: ResolveVariable> EvalContext<'x, '_, V, Expression, &mut Vec> { async fn eval(&mut self) -> trc::Result> { let mut stack = Vec::new(); let mut exprs = self.expr.items.iter(); @@ -256,7 +256,7 @@ impl<'x, 'y, V: ResolveVariable> EvalContext<'x, 'y, V, Expression, &mut Vec { - if stack.last().map_or(false, |v| v.to_bool()) == *val { + if stack.last().is_some_and(|v| v.to_bool()) == *val { for _ in 0..*pos { exprs.next(); } diff --git a/crates/common/src/expr/functions/asynch.rs b/crates/common/src/expr/functions/asynch.rs index abc2b654b..7c6c97b81 100644 --- a/crates/common/src/expr/functions/asynch.rs +++ b/crates/common/src/expr/functions/asynch.rs @@ -125,7 +125,7 @@ impl Server { if query .as_bytes() .get(..6) - .map_or(false, |q| q.eq_ignore_ascii_case(b"SELECT")) + .is_some_and(|q| q.eq_ignore_ascii_case(b"SELECT")) { let mut rows = store .sql_query::(&query, arguments) diff --git a/crates/common/src/expr/functions/misc.rs b/crates/common/src/expr/functions/misc.rs index 06776c851..004b5d745 100644 --- a/crates/common/src/expr/functions/misc.rs +++ b/crates/common/src/expr/functions/misc.rs @@ -30,14 +30,14 @@ pub(crate) fn fn_is_ip_addr(v: Vec) -> Variable { pub(crate) fn fn_is_ipv4_addr(v: Vec) -> Variable { v[0].to_string() .parse::() - .map_or(false, |ip| matches!(ip, IpAddr::V4(_))) + .is_ok_and(|ip| matches!(ip, IpAddr::V4(_))) .into() } pub(crate) fn fn_is_ipv6_addr(v: Vec) -> Variable { v[0].to_string() .parse::() - .map_or(false, |ip| matches!(ip, IpAddr::V6(_))) + .is_ok_and(|ip| matches!(ip, IpAddr::V6(_))) .into() } diff --git a/crates/common/src/expr/tokenizer.rs b/crates/common/src/expr/tokenizer.rs index 1c687d414..b7534c5d6 100644 --- a/crates/common/src/expr/tokenizer.rs +++ b/crates/common/src/expr/tokenizer.rs @@ -76,7 +76,7 @@ impl<'x> Tokenizer<'x> { self.is_eof = true; break; } - b'-' if self.buf.last().map_or(false, |c| *c == b'[') => { + b'-' if self.buf.last().is_some_and(|c| *c == b'[') => { self.buf.push(ch); } b':' if self.buf.contains(&b'.') => { @@ -85,7 +85,7 @@ impl<'x> Tokenizer<'x> { b']' if self.buf.contains(&b'[') => { self.buf.push(b']'); } - b'*' if self.buf.last().map_or(false, |&c| c == b'[' || c == b'.') => { + b'*' if self.buf.last().is_some_and(|&c| c == b'[' || c == b'.') => { self.buf.push(ch); } _ => { diff --git a/crates/common/src/listener/asn.rs b/crates/common/src/listener/asn.rs index 9bb2def06..54ffbe47b 100644 --- a/crates/common/src/listener/asn.rs +++ b/crates/common/src/listener/asn.rs @@ -93,9 +93,9 @@ impl Server { if !part.is_empty() { if idx == *index_asn { asn = part.parse::().ok(); - } else if index_asn_name.map_or(false, |i| i == idx) { + } else if index_asn_name.is_some_and(|i| i == idx) { asn_name = Some(part.to_string()); - } else if index_country.map_or(false, |i| i == idx) { + } else if index_country.is_some_and(|i| i == idx) { country = Some(part.to_string()); } } diff --git a/crates/common/src/listener/stream.rs b/crates/common/src/listener/stream.rs index 4f5e18a85..dca58d940 100644 --- a/crates/common/src/listener/stream.rs +++ b/crates/common/src/listener/stream.rs @@ -68,7 +68,7 @@ impl SessionStream for ProxiedStream { fn is_tls(&self) -> bool { self.proxy_header() .ssl() - .map_or(false, |ssl| ssl.client_ssl()) + .is_some_and(|ssl| ssl.client_ssl()) } fn tls_version_and_cipher(&self) -> (Cow<'static, str>, Cow<'static, str>) { diff --git a/crates/common/src/manager/config.rs b/crates/common/src/manager/config.rs index 79b82724e..351d8eeb9 100644 --- a/crates/common/src/manager/config.rs +++ b/crates/common/src/manager/config.rs @@ -454,7 +454,7 @@ impl ConfigManager { { let is_tls = listener .get("tls.implicit") - .map_or(false, |tls| tls == "true"); + .is_some_and(|tls| tls == "true"); let protocol = listener .get("protocol") .map(|s| s.as_str()) diff --git a/crates/common/src/manager/mod.rs b/crates/common/src/manager/mod.rs index 342adf86f..51861a82c 100644 --- a/crates/common/src/manager/mod.rs +++ b/crates/common/src/manager/mod.rs @@ -108,7 +108,7 @@ pub async fn fetch_resource( pub fn is_localhost_url(url: &str) -> bool { url.split_once("://") .map(|(_, url)| url.split_once('/').map_or(url, |(host, _)| host)) - .map_or(false, |host| { + .is_some_and(|host| { let host = host.rsplit_once(':').map_or(host, |(host, _)| host); host == "localhost" || host == "127.0.0.1" || host == "[::1]" }) diff --git a/crates/common/src/scripts/functions/misc.rs b/crates/common/src/scripts/functions/misc.rs index 00c3b8c29..d56137fcf 100644 --- a/crates/common/src/scripts/functions/misc.rs +++ b/crates/common/src/scripts/functions/misc.rs @@ -33,14 +33,14 @@ pub fn fn_is_ip_addr<'x>(_: &'x Context<'x>, v: Vec) -> Variable { pub fn fn_is_ipv4_addr<'x>(_: &'x Context<'x>, v: Vec) -> Variable { v[0].to_string() .parse::() - .map_or(false, |ip| matches!(ip, IpAddr::V4(_))) + .is_ok_and(|ip| matches!(ip, IpAddr::V4(_))) .into() } pub fn fn_is_ipv6_addr<'x>(_: &'x Context<'x>, v: Vec) -> Variable { v[0].to_string() .parse::() - .map_or(false, |ip| matches!(ip, IpAddr::V6(_))) + .is_ok_and(|ip| matches!(ip, IpAddr::V6(_))) .into() } diff --git a/crates/common/src/scripts/mod.rs b/crates/common/src/scripts/mod.rs index 0ffbb9aee..a40e067df 100644 --- a/crates/common/src/scripts/mod.rs +++ b/crates/common/src/scripts/mod.rs @@ -72,6 +72,6 @@ impl> IsMixedCharset for T { } } - set.map_or(false, |set| set.is_empty()) + set.is_some_and(|set| set.is_empty()) } } diff --git a/crates/common/src/scripts/plugins/query.rs b/crates/common/src/scripts/plugins/query.rs index f908645ac..70f918b70 100644 --- a/crates/common/src/scripts/plugins/query.rs +++ b/crates/common/src/scripts/plugins/query.rs @@ -46,7 +46,7 @@ pub async fn exec(ctx: PluginContext<'_>) -> trc::Result { if query .as_bytes() .get(..6) - .map_or(false, |q| q.eq_ignore_ascii_case(b"SELECT")) + .is_some_and(|q| q.eq_ignore_ascii_case(b"SELECT")) { let mut rows = store.sql_query::(&query, arguments).await?; Ok(match rows.rows.len().cmp(&1) { diff --git a/crates/directory/src/backend/internal/lookup.rs b/crates/directory/src/backend/internal/lookup.rs index a9a439586..783b1ffd0 100644 --- a/crates/directory/src/backend/internal/lookup.rs +++ b/crates/directory/src/backend/internal/lookup.rs @@ -91,7 +91,7 @@ impl DirectoryStore for Store { DirectoryClass::NameToId(domain.as_bytes().to_vec()), ))) .await - .map(|p| p.map_or(false, |p| p.typ == Type::Domain)) + .map(|p| p.is_some_and(|p| p.typ == Type::Domain)) } async fn rcpt(&self, address: &str) -> trc::Result { diff --git a/crates/directory/src/backend/internal/manage.rs b/crates/directory/src/backend/internal/manage.rs index 653dd3280..5958eb579 100644 --- a/crates/directory/src/backend/internal/manage.rs +++ b/crates/directory/src/backend/internal/manage.rs @@ -598,7 +598,7 @@ impl ManageDirectory for Store { .filter(|v| { v.name() .rsplit_once('@') - .map_or(false, |(_, d)| d.eq_ignore_ascii_case(name)) + .is_some_and(|(_, d)| d.eq_ignore_ascii_case(name)) }) .collect::>(); let total_domain_members = domain_members.len(); @@ -1794,7 +1794,7 @@ impl ManageDirectory for Store { if std::str::from_utf8(key.get(1..).unwrap_or_default()) .unwrap_or_default() .rsplit_once('@') - .map_or(false, |(_, domain)| domain == domain_name) + .is_some_and(|(_, domain)| domain == domain_name) { total += 1; } diff --git a/crates/directory/src/backend/internal/mod.rs b/crates/directory/src/backend/internal/mod.rs index 8130a21d7..b1bcd8f55 100644 --- a/crates/directory/src/backend/internal/mod.rs +++ b/crates/directory/src/backend/internal/mod.rs @@ -106,7 +106,7 @@ impl PrincipalInfo { pub fn has_tenant_access(&self, tenant_id: Option) -> bool { tenant_id.map_or(true, |tenant_id| { - self.tenant.map_or(false, |t| tenant_id == t) + self.tenant.is_some_and(|t| tenant_id == t) || (self.typ == Type::Tenant && self.id == tenant_id) }) } diff --git a/crates/directory/src/backend/ldap/lookup.rs b/crates/directory/src/backend/ldap/lookup.rs index 027804792..ad4707391 100644 --- a/crates/directory/src/backend/ldap/lookup.rs +++ b/crates/directory/src/backend/ldap/lookup.rs @@ -112,7 +112,7 @@ impl LdapDirectory { && err .value(trc::Key::Code) .and_then(|v| v.to_uint()) - .map_or(false, |rc| [49, 50].contains(&rc)) => + .is_some_and(|rc| [49, 50].contains(&rc)) => { return Ok(None); } diff --git a/crates/directory/src/core/principal.rs b/crates/directory/src/core/principal.rs index 79f6ecd5a..a274f2a5d 100644 --- a/crates/directory/src/core/principal.rs +++ b/crates/directory/src/core/principal.rs @@ -291,7 +291,7 @@ impl Principal { } pub fn has_str_value(&self, key: PrincipalField, value: &str) -> bool { - self.fields.get(&key).map_or(false, |v| match v { + self.fields.get(&key).is_some_and(|v| match v { PrincipalValue::String(v) => v == value, PrincipalValue::StringList(l) => l.iter().any(|v| v == value), PrincipalValue::Integer(_) | PrincipalValue::IntegerList(_) => false, @@ -299,7 +299,7 @@ impl Principal { } pub fn has_int_value(&self, key: PrincipalField, value: u64) -> bool { - self.fields.get(&key).map_or(false, |v| match v { + self.fields.get(&key).is_some_and(|v| match v { PrincipalValue::Integer(v) => *v == value, PrincipalValue::IntegerList(l) => l.iter().any(|v| *v == value), PrincipalValue::String(_) | PrincipalValue::StringList(_) => false, diff --git a/crates/imap-proto/src/parser/fetch.rs b/crates/imap-proto/src/parser/fetch.rs index f4ff46df3..52c2ec5ff 100644 --- a/crates/imap-proto/src/parser/fetch.rs +++ b/crates/imap-proto/src/parser/fetch.rs @@ -74,7 +74,7 @@ impl Request { attributes.push_unique(Attribute::Uid); } else if value.eq_ignore_ascii_case(b"RFC822") { attributes.push_unique( - if tokens.peek().map_or(false, |token| token.is_dot()) { + if tokens.peek().is_some_and(|token| token.is_dot()) { tokens.next(); let rfc822 = tokens .next() diff --git a/crates/imap-proto/src/parser/list.rs b/crates/imap-proto/src/parser/list.rs index 752e42aaa..16688e288 100644 --- a/crates/imap-proto/src/parser/list.rs +++ b/crates/imap-proto/src/parser/list.rs @@ -105,7 +105,7 @@ impl Request { if tokens .next() - .map_or(false, |token| token.eq_ignore_ascii_case(b"return")) + .is_some_and(|token| token.eq_ignore_ascii_case(b"return")) { if tokens .next() diff --git a/crates/imap/src/op/fetch.rs b/crates/imap/src/op/fetch.rs index be2b1fc8f..fa0ae8ee8 100644 --- a/crates/imap/src/op/fetch.rs +++ b/crates/imap/src/op/fetch.rs @@ -217,7 +217,7 @@ impl SessionData { for attribute in &arguments.attributes { match attribute { Attribute::BodySection { sections, .. } - if sections.first().map_or(false, |s| { + if sections.first().is_some_and(|s| { matches!(s, Section::Header | Section::HeaderFields { .. }) }) => {} Attribute::Body | Attribute::BodyStructure | Attribute::BinarySize { .. } => { diff --git a/crates/imap/src/op/status.rs b/crates/imap/src/op/status.rs index d06ae5820..75ac01daa 100644 --- a/crates/imap/src/op/status.rs +++ b/crates/imap/src/op/status.rs @@ -90,7 +90,7 @@ impl SessionData { return if mailbox_name == self.server.core.jmap.shared_folder || mailbox_name .split_once('/') - .map_or(false, |(base_name, path)| { + .is_some_and(|(base_name, path)| { base_name == self.server.core.jmap.shared_folder && !path.contains('/') }) { diff --git a/crates/jmap-proto/src/method/set.rs b/crates/jmap-proto/src/method/set.rs index 35bc71a32..eb144e6f4 100644 --- a/crates/jmap-proto/src/method/set.rs +++ b/crates/jmap-proto/src/method/set.rs @@ -411,11 +411,11 @@ impl SetRequest { } pub fn has_updates(&self) -> bool { - self.update.as_ref().map_or(false, |objs| !objs.is_empty()) + self.update.as_ref().is_some_and(|objs| !objs.is_empty()) } pub fn has_creates(&self) -> bool { - self.create.as_ref().map_or(false, |objs| !objs.is_empty()) + self.create.as_ref().is_some_and(|objs| !objs.is_empty()) } pub fn unwrap_create(&mut self) -> VecMap> { diff --git a/crates/jmap/src/api/autoconfig.rs b/crates/jmap/src/api/autoconfig.rs index 72c5a31ca..f1b2d9eff 100644 --- a/crates/jmap/src/api/autoconfig.rs +++ b/crates/jmap/src/api/autoconfig.rs @@ -212,7 +212,7 @@ impl Autoconfig for Server { if principal .get_str_array(PrincipalField::Emails) .and_then(|emails| emails.first()) - .map_or(false, |email| email.eq_ignore_ascii_case(emailaddress)) + .is_some_and(|email| email.eq_ignore_ascii_case(emailaddress)) { account_name = principal.take_str(PrincipalField::Name).unwrap_or_default(); } diff --git a/crates/jmap/src/api/form.rs b/crates/jmap/src/api/form.rs index 3d351d6a1..34e87d791 100644 --- a/crates/jmap/src/api/form.rs +++ b/crates/jmap/src/api/form.rs @@ -80,7 +80,7 @@ impl FormHandler for Server { if form .field_honey_pot .as_ref() - .map_or(false, |field| form_data.has_field(field)) + .is_some_and(|field| form_data.has_field(field)) { return Err(trc::ResourceEvent::BadParameters .into_err() diff --git a/crates/jmap/src/api/management/dns.rs b/crates/jmap/src/api/management/dns.rs index df6cfe4dd..420e02377 100644 --- a/crates/jmap/src/api/management/dns.rs +++ b/crates/jmap/src/api/management/dns.rs @@ -109,10 +109,7 @@ impl DnsManagement for Server { name: format!("{domain_name}."), content: format!("10 {server_name}."), }); - if server_name - .strip_prefix("mail.") - .map_or(true, |s| s != domain_name) - { + if server_name.strip_prefix("mail.") != Some(domain_name) { records.push(DnsRecord { typ: "CNAME".to_string(), name: format!("mail.{domain_name}."), diff --git a/crates/jmap/src/api/management/enterprise/telemetry.rs b/crates/jmap/src/api/management/enterprise/telemetry.rs index 7bdfc97b2..7354f7748 100644 --- a/crates/jmap/src/api/management/enterprise/telemetry.rs +++ b/crates/jmap/src/api/management/enterprise/telemetry.rs @@ -222,7 +222,7 @@ impl TelemetryApi for Server { if (filter.is_none() && key_filters.is_empty()) || event .span_id() - .map_or(false, |span_id| active_span_ids.contains(&span_id)) + .is_some_and(|span_id| active_span_ids.contains(&span_id)) { events.push(event); } else { diff --git a/crates/jmap/src/api/management/principal.rs b/crates/jmap/src/api/management/principal.rs index 3fb9f6495..cae93666c 100644 --- a/crates/jmap/src/api/management/principal.rs +++ b/crates/jmap/src/api/management/principal.rs @@ -274,7 +274,7 @@ impl PrincipalManager for Server { .into_err() .details("Invalid type") })?; - if params.get("confirm").map_or(true, |c| c != "true") { + if params.get("confirm") != Some("true") { return Err(trc::EventType::Resource(trc::ResourceEvent::BadParameters) .into_err() .details("Missing confirmation parameter")); @@ -330,7 +330,7 @@ impl PrincipalManager for Server { .spam .bayes .as_ref() - .map_or(false, |c| c.account_classify); + .is_some_and(|c| c.account_classify); for principal in principals.items { // Delete account if let Err(err) = server @@ -478,7 +478,7 @@ impl PrincipalManager for Server { .spam .bayes .as_ref() - .map_or(false, |c| c.account_classify) + .is_some_and(|c| c.account_classify) { let mut key = Vec::with_capacity(std::mem::size_of::() + 1); key.push(KV_BAYES_MODEL_USER); diff --git a/crates/jmap/src/api/management/report.rs b/crates/jmap/src/api/management/report.rs index 0164a9240..7185059dc 100644 --- a/crates/jmap/src/api/management/report.rs +++ b/crates/jmap/src/api/management/report.rs @@ -472,7 +472,7 @@ impl Contains for mail_auth::report::Report { || self.report_id().contains(text) || self .extra_contact_info() - .map_or(false, |c| c.to_lowercase().contains(text)) + .is_some_and(|c| c.to_lowercase().contains(text)) || self.records().iter().any(|record| record.contains(text)) } } @@ -481,22 +481,22 @@ impl Contains for mail_auth::report::Record { fn contains(&self, filter: &str) -> bool { self.envelope_from().contains(filter) || self.header_from().contains(filter) - || self.envelope_to().map_or(false, |to| to.contains(filter)) + || self.envelope_to().is_some_and(|to| to.contains(filter)) || self.dkim_auth_result().iter().any(|dkim| { dkim.domain().contains(filter) || dkim.selector().contains(filter) || dkim .human_result() .as_ref() - .map_or(false, |r| r.contains(filter)) + .is_some_and(|r| r.contains(filter)) }) || self.spf_auth_result().iter().any(|spf| { spf.domain().contains(filter) - || spf.human_result().map_or(false, |r| r.contains(filter)) + || spf.human_result().is_some_and(|r| r.contains(filter)) }) || self .source_ip() - .map_or(false, |ip| ip.to_string().contains(filter)) + .is_some_and(|ip| ip.to_string().contains(filter)) } } @@ -504,11 +504,11 @@ impl Contains for TlsReport { fn contains(&self, text: &str) -> bool { self.organization_name .as_ref() - .map_or(false, |o| o.to_lowercase().contains(text)) + .is_some_and(|o| o.to_lowercase().contains(text)) || self .contact_info .as_ref() - .map_or(false, |c| c.to_lowercase().contains(text)) + .is_some_and(|c| c.to_lowercase().contains(text)) || self.report_id.contains(text) || self.policies.iter().any(|p| p.contains(text)) } @@ -534,26 +534,26 @@ impl Contains for Policy { impl Contains for FailureDetails { fn contains(&self, filter: &str) -> bool { self.sending_mta_ip - .map_or(false, |s| s.to_string().contains(filter)) + .is_some_and(|s| s.to_string().contains(filter)) || self .receiving_ip - .map_or(false, |s| s.to_string().contains(filter)) + .is_some_and(|s| s.to_string().contains(filter)) || self .receiving_mx_hostname .as_ref() - .map_or(false, |s| s.contains(filter)) + .is_some_and(|s| s.contains(filter)) || self .receiving_mx_helo .as_ref() - .map_or(false, |s| s.contains(filter)) + .is_some_and(|s| s.contains(filter)) || self .additional_information .as_ref() - .map_or(false, |s| s.contains(filter)) + .is_some_and(|s| s.contains(filter)) || self .failure_reason_code .as_ref() - .map_or(false, |s| s.contains(filter)) + .is_some_and(|s| s.contains(filter)) } } @@ -565,29 +565,27 @@ impl Contains for Feedback<'_> { .any(|s| s.contains(text)) || self .original_envelope_id() - .map_or(false, |s| s.contains(text)) - || self - .original_mail_from() - .map_or(false, |s| s.contains(text)) - || self.original_rcpt_to().map_or(false, |s| s.contains(text)) + .is_some_and(|s| s.contains(text)) + || self.original_mail_from().is_some_and(|s| s.contains(text)) + || self.original_rcpt_to().is_some_and(|s| s.contains(text)) || self.reported_domain().iter().any(|s| s.contains(text)) || self.reported_uri().iter().any(|s| s.contains(text)) - || self.reporting_mta().map_or(false, |s| s.contains(text)) - || self.user_agent().map_or(false, |s| s.contains(text)) - || self.dkim_adsp_dns().map_or(false, |s| s.contains(text)) + || self.reporting_mta().is_some_and(|s| s.contains(text)) + || self.user_agent().is_some_and(|s| s.contains(text)) + || self.dkim_adsp_dns().is_some_and(|s| s.contains(text)) || self .dkim_canonicalized_body() - .map_or(false, |s| s.contains(text)) + .is_some_and(|s| s.contains(text)) || self .dkim_canonicalized_header() - .map_or(false, |s| s.contains(text)) - || self.dkim_domain().map_or(false, |s| s.contains(text)) - || self.dkim_identity().map_or(false, |s| s.contains(text)) - || self.dkim_selector().map_or(false, |s| s.contains(text)) - || self.dkim_selector_dns().map_or(false, |s| s.contains(text)) - || self.spf_dns().map_or(false, |s| s.contains(text)) - || self.message().map_or(false, |s| s.contains(text)) - || self.headers().map_or(false, |s| s.contains(text)) + .is_some_and(|s| s.contains(text)) + || self.dkim_domain().is_some_and(|s| s.contains(text)) + || self.dkim_identity().is_some_and(|s| s.contains(text)) + || self.dkim_selector().is_some_and(|s| s.contains(text)) + || self.dkim_selector_dns().is_some_and(|s| s.contains(text)) + || self.spf_dns().is_some_and(|s| s.contains(text)) + || self.message().is_some_and(|s| s.contains(text)) + || self.headers().is_some_and(|s| s.contains(text)) } } diff --git a/crates/jmap/src/auth/oauth/auth.rs b/crates/jmap/src/auth/oauth/auth.rs index 89b0fb0b9..3fa4518cb 100644 --- a/crates/jmap/src/auth/oauth/auth.rs +++ b/crates/jmap/src/auth/oauth/auth.rs @@ -92,7 +92,7 @@ impl OAuthApiHandler for Server { .details("Client ID is invalid.")); } else if redirect_uri .as_ref() - .map_or(false, |uri| uri.starts_with("http://")) + .is_some_and(|uri| uri.starts_with("http://")) { return Err(trc::ManageEvent::Error .into_err() diff --git a/crates/jmap/src/auth/oauth/mod.rs b/crates/jmap/src/auth/oauth/mod.rs index c9fe1af82..2cde060ea 100644 --- a/crates/jmap/src/auth/oauth/mod.rs +++ b/crates/jmap/src/auth/oauth/mod.rs @@ -216,7 +216,7 @@ impl FormData { } pub fn has_field(&self, key: &str) -> bool { - self.fields.get(key).map_or(false, |v| !v.is_empty()) + self.fields.get(key).is_some_and(|v| !v.is_empty()) } pub fn fields(&self) -> impl Iterator { diff --git a/crates/jmap/src/changes/query.rs b/crates/jmap/src/changes/query.rs index bfcb1517d..bcaa76a70 100644 --- a/crates/jmap/src/changes/query.rs +++ b/crates/jmap/src/changes/query.rs @@ -84,7 +84,7 @@ impl QueryChanges for Server { || query .sort .as_ref() - .map_or(false, |sort| sort.iter().any(|s| !s.is_immutable())); + .is_some_and(|sort| sort.iter().any(|s| !s.is_immutable())); let results = match request.arguments { query::RequestArguments::Email(arguments) => { self.email_query(query.with_arguments(arguments), access_token) diff --git a/crates/jmap/src/email/bayes.rs b/crates/jmap/src/email/bayes.rs index f0027e42d..629ab1109 100644 --- a/crates/jmap/src/email/bayes.rs +++ b/crates/jmap/src/email/bayes.rs @@ -85,7 +85,7 @@ impl EmailBayesTrain for Server { } fn email_bayes_can_train(&self, access_token: &AccessToken) -> bool { - self.core.spam.bayes.as_ref().map_or(false, |bayes| { + self.core.spam.bayes.as_ref().is_some_and(|bayes| { bayes.account_classify && access_token.has_permission(Permission::SpamFilterTrain) }) } diff --git a/crates/jmap/src/email/crypto.rs b/crates/jmap/src/email/crypto.rs index 627f30c1f..fe05f4f05 100644 --- a/crates/jmap/src/email/crypto.rs +++ b/crates/jmap/src/email/crypto.rs @@ -372,7 +372,7 @@ impl EncryptMessage for Message<'_> { } fn is_encrypted(&self) -> bool { - self.content_type().map_or(false, |ct| { + self.content_type().is_some_and(|ct| { let main_type = ct.c_type.as_ref(); let sub_type = ct .c_subtype @@ -384,10 +384,9 @@ impl EncryptMessage for Message<'_> { && (sub_type.eq_ignore_ascii_case("pkcs7-mime") || sub_type.eq_ignore_ascii_case("pkcs7-signature") || (sub_type.eq_ignore_ascii_case("octet-stream") - && self.attachment_name().map_or(false, |name| { - name.rsplit_once('.').map_or(false, |(_, ext)| { - ["p7m", "p7s", "p7c", "p7z"].contains(&ext) - }) + && self.attachment_name().is_some_and(|name| { + name.rsplit_once('.') + .is_some_and(|(_, ext)| ["p7m", "p7s", "p7c", "p7z"].contains(&ext)) })))) || (main_type.eq_ignore_ascii_case("multipart") && sub_type.eq_ignore_ascii_case("encrypted")) @@ -514,13 +513,13 @@ fn try_parse_pem( // Find type let tag = std::str::from_utf8(&buf).unwrap(); if tag.contains("CERTIFICATE") { - if method.map_or(false, |m| m == EncryptionMethod::PGP) { + if method.is_some_and(|m| m == EncryptionMethod::PGP) { return Err("Cannot mix OpenPGP and S/MIME certificates".into()); } else { method = Some(EncryptionMethod::SMIME); } } else if tag.contains("PGP") { - if method.map_or(false, |m| m == EncryptionMethod::SMIME) { + if method.is_some_and(|m| m == EncryptionMethod::SMIME) { return Err("Cannot mix OpenPGP and S/MIME certificates".into()); } else { method = Some(EncryptionMethod::PGP); diff --git a/crates/jmap/src/email/ingest.rs b/crates/jmap/src/email/ingest.rs index 4b04c0488..518227566 100644 --- a/crates/jmap/src/email/ingest.rs +++ b/crates/jmap/src/email/ingest.rs @@ -157,7 +157,7 @@ impl EmailIngest for Server { .status .as_ref() .and_then(|name| message.header(name.as_str()).and_then(|v| v.as_text())) - .map_or(false, |v| v.contains("Yes")); + .is_some_and(|v| v.contains("Yes")); // Classify the message with user's model if let Some(bayes_config) = self diff --git a/crates/jmap/src/email/set.rs b/crates/jmap/src/email/set.rs index d502bd866..df12ea6ac 100644 --- a/crates/jmap/src/email/set.rs +++ b/crates/jmap/src/email/set.rs @@ -435,7 +435,7 @@ impl EmailSet for Server { } } else if expected_content_type .as_ref() - .map_or(false, |v| v != &content_type) + .is_some_and(|v| v != &content_type) { response.not_created.append( id, diff --git a/crates/jmap/src/mailbox/query.rs b/crates/jmap/src/mailbox/query.rs index 33263db95..46f1c3eba 100644 --- a/crates/jmap/src/mailbox/query.rs +++ b/crates/jmap/src/mailbox/query.rs @@ -115,7 +115,7 @@ impl MailboxQuery for Server { let mut tree = AHashMap::default(); if (filter_as_tree || sort_as_tree) && (paginate.is_some() - || (response.total.map_or(false, |total| total > 0) && filter_as_tree)) + || (response.total.is_some_and(|total| total > 0) && filter_as_tree)) { for (document_id, value) in self .get_properties::, _, _>( diff --git a/crates/jmap/src/mailbox/set.rs b/crates/jmap/src/mailbox/set.rs index beaca13d5..6baad5337 100644 --- a/crates/jmap/src/mailbox/set.rs +++ b/crates/jmap/src/mailbox/set.rs @@ -724,7 +724,7 @@ impl MailboxSet for Server { } // Role of internal folders cannot be modified - if update.as_ref().map_or(false, |(document_id, _)| { + if update.as_ref().is_some_and(|(document_id, _)| { *document_id == INBOX_ID || *document_id == TRASH_ID }) { return Ok(Err(SetError::invalid_properties() diff --git a/crates/jmap/src/push/get.rs b/crates/jmap/src/push/get.rs index 41692f9bc..3554748e9 100644 --- a/crates/jmap/src/push/get.rs +++ b/crates/jmap/src/push/get.rs @@ -210,7 +210,7 @@ impl PushSubscriptionFetch for Server { .properties .get(&Property::VerificationCode) .and_then(|p| p.as_string()) - .map_or(false, |v| v == verification_code) + .is_some_and(|v| v == verification_code) { let types = if let Some(Value::List(value)) = subscription.properties.remove(&Property::Types) diff --git a/crates/jmap/src/push/set.rs b/crates/jmap/src/push/set.rs index d23b94363..f07f12d82 100644 --- a/crates/jmap/src/push/set.rs +++ b/crates/jmap/src/push/set.rs @@ -269,7 +269,7 @@ fn validate_push_value( .unwrap() .properties .get(&Property::Value) - .map_or(false, |v| matches!(v, Value::Text(v) if v == &value)) + .is_some_and(|v| matches!(v, Value::Text(v) if v == &value)) { Value::Text(value) } else { diff --git a/crates/jmap/src/sieve/set.rs b/crates/jmap/src/sieve/set.rs index 0f5f28e9d..2b6d03683 100644 --- a/crates/jmap/src/sieve/set.rs +++ b/crates/jmap/src/sieve/set.rs @@ -638,7 +638,7 @@ impl SieveScriptSet for Server { .results; // Check if script is already active - if activate_id.map_or(false, |id| active_ids.remove(id)) { + if activate_id.is_some_and(|id| active_ids.remove(id)) { if active_ids.is_empty() { return Ok(changed_ids); } else { diff --git a/crates/jmap/src/submission/set.rs b/crates/jmap/src/submission/set.rs index 5c3ff8ec0..08ad593be 100644 --- a/crates/jmap/src/submission/set.rs +++ b/crates/jmap/src/submission/set.rs @@ -260,12 +260,12 @@ impl EmailSubmissionSet for Server { .arguments .on_success_destroy_email .as_ref() - .map_or(false, |p| !p.is_empty()) + .is_some_and(|p| !p.is_empty()) || request .arguments .on_success_update_email .as_ref() - .map_or(false, |p| !p.is_empty())) + .is_some_and(|p| !p.is_empty())) && response.has_changes() { *next_call = Call { diff --git a/crates/nlp/src/bayes/tokenize.rs b/crates/nlp/src/bayes/tokenize.rs index d336f0909..aca494e64 100644 --- a/crates/nlp/src/bayes/tokenize.rs +++ b/crates/nlp/src/bayes/tokenize.rs @@ -72,7 +72,7 @@ impl> Iterator for BayesTokenizer { BayesInputToken::Word(word) => { if self .stop_words - .map_or(false, |sw| sw.contains(word.as_str())) + .is_some_and(|sw| sw.contains(word.as_str())) { continue; } diff --git a/crates/smtp/src/inbound/milter/message.rs b/crates/smtp/src/inbound/milter/message.rs index 7832cbc64..5eebaf6c0 100644 --- a/crates/smtp/src/inbound/milter/message.rs +++ b/crates/smtp/src/inbound/milter/message.rs @@ -483,13 +483,13 @@ impl SessionData { ); for (header, value) in headers { new_message.extend_from_slice(header.as_ref()); - if value.first().map_or(false, |c| c.is_ascii_whitespace()) { + if value.first().is_some_and(|c| c.is_ascii_whitespace()) { new_message.extend_from_slice(b":"); } else { new_message.extend_from_slice(b": "); } new_message.extend_from_slice(value.as_ref()); - if !value.last().map_or(false, |c| *c == b'\n') { + if value.last().is_none_or(|c| *c != b'\n') { new_message.extend_from_slice(b"\r\n"); } } diff --git a/crates/smtp/src/outbound/lookup.rs b/crates/smtp/src/outbound/lookup.rs index 77a6813ca..791ede86b 100644 --- a/crates/smtp/src/outbound/lookup.rs +++ b/crates/smtp/src/outbound/lookup.rs @@ -35,8 +35,8 @@ pub trait DnsLookup: Sync + Send { max_results: usize, ) -> impl Future>> + Send; - fn resolve_host<'x>( - &'x self, + fn resolve_host( + &self, remote_host: &NextHop<'_>, envelope: &impl ResolveVariable, max_multihomed: usize, @@ -114,8 +114,8 @@ impl DnsLookup for Server { } } - async fn resolve_host<'x>( - &'x self, + async fn resolve_host( + &self, remote_host: &NextHop<'_>, envelope: &impl ResolveVariable, max_multihomed: usize, diff --git a/crates/smtp/src/outbound/mod.rs b/crates/smtp/src/outbound/mod.rs index 1268e55e1..8e66ed249 100644 --- a/crates/smtp/src/outbound/mod.rs +++ b/crates/smtp/src/outbound/mod.rs @@ -187,7 +187,7 @@ impl From for Status<(), Error> { } else if err.is_status() & err .status() - .map_or(false, |s| s == reqwest::StatusCode::NOT_FOUND) + .is_some_and(|s| s == reqwest::StatusCode::NOT_FOUND) { Status::PermanentFailure(Error::MtaStsError("Policy not found.".to_string())) } else { diff --git a/crates/smtp/src/outbound/mta_sts/lookup.rs b/crates/smtp/src/outbound/mta_sts/lookup.rs index 92db43f96..03c5d2512 100644 --- a/crates/smtp/src/outbound/mta_sts/lookup.rs +++ b/crates/smtp/src/outbound/mta_sts/lookup.rs @@ -21,7 +21,7 @@ use utils::HttpLimitResponse; const MAX_POLICY_SIZE: usize = 1024 * 1024; pub trait MtaStsLookup: Sync + Send { - fn lookup_mta_sts_policy<'x>( + fn lookup_mta_sts_policy( &self, domain: &str, timeout: Duration, @@ -30,7 +30,7 @@ pub trait MtaStsLookup: Sync + Send { #[allow(unused_variables)] impl MtaStsLookup for Server { - async fn lookup_mta_sts_policy<'x>( + async fn lookup_mta_sts_policy( &self, domain: &str, timeout: Duration, @@ -127,10 +127,7 @@ impl Display for Error { f.write_str("Timeout fetching policy.") } else if err.is_connect() { f.write_str("Could not reach policy host.") - } else if err.is_status() - & err - .status() - .map_or(false, |s| s == reqwest::StatusCode::NOT_FOUND) + } else if err.is_status() && (err.status() == Some(reqwest::StatusCode::NOT_FOUND)) { f.write_str("Policy not found.") } else { diff --git a/crates/smtp/src/queue/manager.rs b/crates/smtp/src/queue/manager.rs index 5ca62de5c..b194563f9 100644 --- a/crates/smtp/src/queue/manager.rs +++ b/crates/smtp/src/queue/manager.rs @@ -129,7 +129,7 @@ impl Queue { OnHold::ConcurrencyLimited { limiters, next_due } => { if !(limiters.iter().any(|l| { l.concurrent.load(Ordering::Relaxed) < l.max_concurrent - }) || next_due.map_or(false, |due| due <= now)) + }) || next_due.is_some_and(|due| due <= now)) { continue; } diff --git a/crates/smtp/src/queue/spool.rs b/crates/smtp/src/queue/spool.rs index d4b6378b2..74e693599 100644 --- a/crates/smtp/src/queue/spool.rs +++ b/crates/smtp/src/queue/spool.rs @@ -475,6 +475,6 @@ impl Message { || self .return_path .rsplit_once('@') - .map_or(false, |(_, domain)| domains.contains(&domain.to_string())) + .is_some_and(|(_, domain)| domains.contains(&domain.to_string())) } } diff --git a/crates/smtp/src/reporting/analysis.rs b/crates/smtp/src/reporting/analysis.rs index 6439a96d4..8a5545582 100644 --- a/crates/smtp/src/reporting/analysis.rs +++ b/crates/smtp/src/reporting/analysis.rs @@ -80,11 +80,11 @@ impl AnalyzeReport for Server { if part .content_type() .and_then(|ct| ct.subtype()) - .map_or(false, |t| t.eq_ignore_ascii_case("xml")) + .is_some_and(|t| t.eq_ignore_ascii_case("xml")) || part .attachment_name() .and_then(|n| n.rsplit_once('.')) - .map_or(false, |(_, e)| e.eq_ignore_ascii_case("xml")) + .is_some_and(|(_, e)| e.eq_ignore_ascii_case("xml")) { reports.push(ReportData { compression: Compression::None, @@ -131,7 +131,7 @@ impl AnalyzeReport for Server { ("tlsrpt", _) | (_, "json") => Format::Tls(()), _ => { if attachment_name - .map_or(false, |n| n.contains(".xml") || n.contains('!')) + .is_some_and(|n| n.contains(".xml") || n.contains('!')) { Format::Dmarc(()) } else { diff --git a/crates/smtp/src/reporting/scheduler.rs b/crates/smtp/src/reporting/scheduler.rs index f15320c25..3ecfec47e 100644 --- a/crates/smtp/src/reporting/scheduler.rs +++ b/crates/smtp/src/reporting/scheduler.rs @@ -49,7 +49,7 @@ impl SpawnReport for mpsc::Receiver { if events .first() .and_then(|e| e.due()) - .map_or(false, |due| due <= now) + .is_some_and(|due| due <= now) { let server_ = server.clone(); tokio::spawn(async move { diff --git a/crates/spam-filter/src/analysis/ehlo.rs b/crates/spam-filter/src/analysis/ehlo.rs index 50e3145c4..3a4896fbf 100644 --- a/crates/spam-filter/src/analysis/ehlo.rs +++ b/crates/spam-filter/src/analysis/ehlo.rs @@ -32,7 +32,7 @@ impl SpamFilterAnalyzeEhlo for Server { .output .iprev_ptr .as_ref() - .map_or(false, |ptr| ptr != &ctx.output.ehlo_host.fqdn) + .is_some_and(|ptr| ptr != &ctx.output.ehlo_host.fqdn) { // Helo does not match reverse IP ctx.result.add_tag("HELO_IPREV_MISMATCH"); diff --git a/crates/spam-filter/src/analysis/html.rs b/crates/spam-filter/src/analysis/html.rs index 21f51d837..545769666 100644 --- a/crates/spam-filter/src/analysis/html.rs +++ b/crates/spam-filter/src/analysis/html.rs @@ -29,7 +29,7 @@ struct Href { impl SpamFilterAnalyzeHtml for Server { async fn spam_filter_analyze_html(&self, ctx: &mut SpamFilterContext<'_>) { // Message only has text/html MIME parts - if ctx.input.message.content_type().map_or(false, |ct| { + if ctx.input.message.content_type().is_some_and(|ct| { ct.ctype().eq_ignore_ascii_case("text") && ct .subtype() @@ -94,7 +94,7 @@ impl SpamFilterAnalyzeHtml for Server { // Uses Data URI encoding to obfuscate plain or HTML in base64 ctx.result.add_tag("DATA_URI_OBFU"); } - } else if href.host.as_ref().map_or(false, |h| h.ip.is_some()) { + } else if href.host.as_ref().is_some_and(|h| h.ip.is_some()) { // HTML anchor points to an IP address ctx.result.add_tag("HTTP_TO_IP"); } diff --git a/crates/spam-filter/src/analysis/llm.rs b/crates/spam-filter/src/analysis/llm.rs index 9a194daaf..062a54271 100644 --- a/crates/spam-filter/src/analysis/llm.rs +++ b/crates/spam-filter/src/analysis/llm.rs @@ -63,12 +63,12 @@ impl SpamFilterAnalyzeLlm for Server { if config.categories.contains(value.as_str()) { category = Some(value); } - } else if config.index_confidence.map_or(false, |i| i == idx) { + } else if config.index_confidence.is_some_and(|i| i == idx) { let value = value.to_uppercase(); if config.confidence.contains(value.as_str()) { confidence = Some(value); } - } else if config.index_explanation.map_or(false, |i| i == idx) { + } else if config.index_explanation.is_some_and(|i| i == idx) { let explanation = explanation.get_or_insert_with(|| { String::with_capacity(std::cmp::min(value.len(), 255)) }); diff --git a/crates/spam-filter/src/analysis/mime.rs b/crates/spam-filter/src/analysis/mime.rs index 198295c25..67a58db7b 100644 --- a/crates/spam-filter/src/analysis/mime.rs +++ b/crates/spam-filter/src/analysis/mime.rs @@ -54,8 +54,8 @@ impl SpamFilterAnalyzeMime for Server { if ct.ctype().eq_ignore_ascii_case("multipart") && ct .subtype() - .map_or(false, |s| s.eq_ignore_ascii_case("report")) - && ct.attribute("report-type").map_or(false, |a| { + .is_some_and(|s| s.eq_ignore_ascii_case("report")) + && ct.attribute("report-type").is_some_and(|a| { a.eq_ignore_ascii_case("delivery-status") || a.eq_ignore_ascii_case("disposition-notification") }) @@ -268,7 +268,7 @@ impl SpamFilterAnalyzeMime for Server { "" | "7bit" => { if raw_message .get(part.raw_body_offset()..part.raw_end_offset()) - .map_or(false, |bytes| !bytes.is_ascii()) + .is_some_and(|bytes| !bytes.is_ascii()) { // MIME text part claims to be ASCII but isn't ctx.result.add_tag("BAD_CTE_7BIT"); @@ -305,7 +305,7 @@ impl SpamFilterAnalyzeMime for Server { ctx.input.message.text_body.contains(&part_id) || ctx.input.message.html_body.contains(&part_id) }) - .map_or(false, |p| match p { + .is_some_and(|p| match p { TextPart::Plain { text_body, .. } => text_body.is_mixed_charset(), TextPart::Html { text_body, .. } => text_body.is_mixed_charset(), TextPart::None => false, @@ -389,14 +389,14 @@ impl SpamFilterAnalyzeMime for Server { if ext.is_bad { // Attachment has a bad extension - if sub_ext.map_or(false, |e| e.is_bad) { + if sub_ext.is_some_and(|e| e.is_bad) { ctx.result.add_tag("MIME_DOUBLE_BAD_EXTENSION"); } else { ctx.result.add_tag("MIME_BAD_EXTENSION"); } } - if ext.is_archive && sub_ext.map_or(false, |e| e.is_archive) { + if ext.is_archive && sub_ext.is_some_and(|e| e.is_archive) { // Archive in archive ctx.result.add_tag("MIME_ARCHIVE_IN_ARCHIVE"); } diff --git a/crates/spam-filter/src/analysis/trusted_reply.rs b/crates/spam-filter/src/analysis/trusted_reply.rs index 3515e0fa9..41eca22cd 100644 --- a/crates/spam-filter/src/analysis/trusted_reply.rs +++ b/crates/spam-filter/src/analysis/trusted_reply.rs @@ -82,7 +82,7 @@ impl SpamFilterAnalyzeTrustedReply for Server { .spam .bayes .as_ref() - .map_or(false, |config| config.auto_learn_reply_ham) + .is_some_and(|config| config.auto_learn_reply_ham) { self.bayes_train_if_balanced(ctx, false).await; } diff --git a/crates/store/src/backend/http/lookup.rs b/crates/store/src/backend/http/lookup.rs index c928764b4..5d8350625 100644 --- a/crates/store/src/backend/http/lookup.rs +++ b/crates/store/src/backend/http/lookup.rs @@ -179,7 +179,7 @@ impl HttpStore { if entry_key.len() > self.config.max_entry_size { break; } - } else if index_value.map_or(false, |v| col_num == v) { + } else if index_value.is_some_and(|v| col_num == v) { entry_value.push(ch); if entry_value.len() > self.config.max_entry_size { break; diff --git a/crates/store/src/config.rs b/crates/store/src/config.rs index 35839b43e..7928896d0 100644 --- a/crates/store/src/config.rs +++ b/crates/store/src/config.rs @@ -402,6 +402,6 @@ impl IsActiveStore for Config { fn is_active_in_memory_store(&self, id: &str) -> bool { self.value("storage.lookup") - .map_or(false, |store_id| store_id == id) + .is_some_and(|store_id| store_id == id) } } diff --git a/crates/store/src/dispatch/store.rs b/crates/store/src/dispatch/store.rs index 9b7f0e37b..5be0066cc 100644 --- a/crates/store/src/dispatch/store.rs +++ b/crates/store/src/dispatch/store.rs @@ -184,7 +184,7 @@ impl Store { pub async fn write(&self, batch: Batch) -> trc::Result { #[cfg(feature = "test_mode")] - if std::env::var("PARANOID_WRITE").map_or(false, |v| v == "1") { + if std::env::var("PARANOID_WRITE").is_ok_and(|v| v == "1") { let mut account_id = u32::MAX; let mut collection = u8::MAX; let mut document_id = u32::MAX; diff --git a/crates/store/src/fts/query.rs b/crates/store/src/fts/query.rs index 7b802a10a..35ea303df 100644 --- a/crates/store/src/fts/query.rs +++ b/crates/store/src/fts/query.rs @@ -296,7 +296,7 @@ impl Store { bm.insert(*document_id); } else if position_candidates .get(document_id) - .map_or(false, |positions| { + .is_some_and(|positions| { postings.matches_positions(positions, pos as u32) }) { @@ -360,7 +360,7 @@ impl Store { bm.insert(document_id); } else if position_candidates .get(&document_id) - .map_or(false, |positions| { + .is_some_and(|positions| { postings.matches_positions(positions, pos as u32) }) { diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index c52323110..7655c57f5 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -102,7 +102,7 @@ impl HttpLimitResponse for Response { async fn bytes_with_limit(self, limit: usize) -> reqwest::Result>> { if self .content_length() - .map_or(false, |len| len as usize > limit) + .is_some_and(|len| len as usize > limit) { return Ok(None); } diff --git a/tests/src/jmap/mod.rs b/tests/src/jmap/mod.rs index c283654a3..4c7765036 100644 --- a/tests/src/jmap/mod.rs +++ b/tests/src/jmap/mod.rs @@ -998,7 +998,7 @@ impl Response { pub fn expect_request_error(self, value: &str) { let err = self.unwrap_request_error(); - if !err.detail.contains(value) && !err.title.as_ref().map_or(false, |t| t.contains(value)) { + if !err.detail.contains(value) && !err.title.as_ref().is_some_and(|t| t.contains(value)) { panic!("Expected request error containing {value:?}, found {err:?}") } } @@ -1006,8 +1006,8 @@ impl Response { pub fn expect_error(self, value: &str) { let (error, details, reason) = self.unwrap_error(); if !error.contains(value) - && !details.as_ref().map_or(false, |d| d.contains(value)) - && !reason.as_ref().map_or(false, |r| r.contains(value)) + && !details.as_ref().is_some_and(|d| d.contains(value)) + && !reason.as_ref().is_some_and(|r| r.contains(value)) { panic!("Expected error containing {value:?}, found {error:?}: {details:?} {reason:?}") } diff --git a/tests/src/jmap/push_subscription.rs b/tests/src/jmap/push_subscription.rs index 8373f7beb..fbcd0d0e1 100644 --- a/tests/src/jmap/push_subscription.rs +++ b/tests/src/jmap/push_subscription.rs @@ -313,7 +313,7 @@ impl common::listener::SessionManager for SessionManager { let is_encrypted = req .headers() .get(CONTENT_ENCODING) - .map_or(false, |encoding| { + .is_some_and(|encoding| { encoding.to_str().unwrap() == "aes128gcm" }); let body = fetch_body(&mut req, 1024 * 1024, 0).await.unwrap();