Skip to content

Commit 17ea75a

Browse files
committed
clippy 📎
1 parent 1c6a23c commit 17ea75a

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

‎crates/data-model/src/oauth2/authorization_grant.rs‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,14 @@ impl AuthorizationGrant {
187187
self.created_at - max_age
188188
}
189189

190-
pub fn parse_login_hint(&self, homeserver: BoxHomeserverConnection) -> LoginHint {
190+
#[must_use]
191+
pub fn parse_login_hint(&self, homeserver: &BoxHomeserverConnection) -> LoginHint {
191192
let Some(login_hint) = &self.login_hint else {
192193
return LoginHint::None;
193194
};
194195

195196
// Return none if the format is incorrect
196-
let Some((prefix, value)) = login_hint.split_once(":") else {
197+
let Some((prefix, value)) = login_hint.split_once(':') else {
197198
return LoginHint::None;
198199
};
199200

@@ -304,7 +305,7 @@ mod tests {
304305
..AuthorizationGrant::sample(Utc::now(), &mut rng)
305306
};
306307

307-
let hint = grant.parse_login_hint(get_homeserver());
308+
let hint = grant.parse_login_hint(&get_homeserver());
308309

309310
assert!(matches!(hint, LoginHint::None));
310311
}
@@ -319,7 +320,7 @@ mod tests {
319320
..AuthorizationGrant::sample(Utc::now(), &mut rng)
320321
};
321322

322-
let hint = grant.parse_login_hint(get_homeserver());
323+
let hint = grant.parse_login_hint(&get_homeserver());
323324

324325
assert!(matches!(hint, LoginHint::MXID(mxid) if mxid.localpart() == "example-user"));
325326
}
@@ -334,7 +335,7 @@ mod tests {
334335
..AuthorizationGrant::sample(Utc::now(), &mut rng)
335336
};
336337

337-
let hint = grant.parse_login_hint(get_homeserver());
338+
let hint = grant.parse_login_hint(&get_homeserver());
338339

339340
assert!(matches!(hint, LoginHint::None));
340341
}
@@ -349,7 +350,7 @@ mod tests {
349350
..AuthorizationGrant::sample(Utc::now(), &mut rng)
350351
};
351352

352-
let hint = grant.parse_login_hint(get_homeserver());
353+
let hint = grant.parse_login_hint(&get_homeserver());
353354

354355
assert!(matches!(hint, LoginHint::None));
355356
}
@@ -364,7 +365,7 @@ mod tests {
364365
..AuthorizationGrant::sample(Utc::now(), &mut rng)
365366
};
366367

367-
let hint = grant.parse_login_hint(get_homeserver());
368+
let hint = grant.parse_login_hint(&get_homeserver());
368369

369370
assert!(matches!(hint, LoginHint::None));
370371
}

‎crates/handlers/src/views/login.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ async fn login(
296296
fn handle_login_hint(
297297
ctx: &mut LoginContext,
298298
next: &PostAuthContext,
299-
homeserver: BoxHomeserverConnection,
299+
homeserver: &BoxHomeserverConnection,
300300
) {
301301
let form_state = ctx.form_state_mut();
302302

@@ -307,7 +307,7 @@ fn handle_login_hint(
307307

308308
if let PostAuthContextInner::ContinueAuthorizationGrant { ref grant } = next.ctx {
309309
let value = match grant.parse_login_hint(homeserver) {
310-
LoginHint::MXID(mxid) => Some(mxid.localpart().to_string()),
310+
LoginHint::MXID(mxid) => Some(mxid.localpart().to_owned()),
311311
LoginHint::None => None,
312312
};
313313
form_state.set_value(LoginFormField::Username, value);
@@ -325,7 +325,7 @@ async fn render(
325325
) -> Result<String, FancyError> {
326326
let next = action.load_context(repo).await?;
327327
let ctx = if let Some(next) = next {
328-
handle_login_hint(&mut ctx, &next, homeserver);
328+
handle_login_hint(&mut ctx, &next, &homeserver);
329329

330330
ctx.with_post_action(next)
331331
} else {

‎crates/templates/src/forms.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ impl<K: FormField> FormState<K> {
175175
pub fn has_value(&self, field: K) -> bool {
176176
self.fields
177177
.get(&field)
178-
.map(|f| f.value.is_some())
179-
.unwrap_or(false)
178+
.is_some_and(|f| f.value.is_some())
180179
}
181180

182181
/// Returns `true` if the form has no error attached to it

0 commit comments

Comments
 (0)