Skip to contentSlop Block

prefer-extension-trait

Hint

Consider a trait method when a free function takes &PgPool, &Context or a similar type first.

async fn process_transcript(connection: &PgPool, body: &Body) -> Result<()> {This free function takes $TYPE as its first parameter	return Ok(());}
fn get_user<'c>(context: &Context<'c>) -> Result<&'c User> {This free function takes $TYPE as its first parameter	return context.get::<User>();}
// ast-grep-ignore: prefer-extension-trait-rust

How to fix

Move it to an extension trait on that type, or to a repository trait when it runs queries.