Would like to make this function generic but having trouble specifying the bounds for parameter T
Errors : 1)'cannot find type DB
in this scope
not found in this scope'
Not sure if I was supposed to include ::bind
either. I got that from rust-analyzer
pub async fn set_db_value<
'q,
T: std::marker::Sync
+ std::marker::Send
+ sqlx::query::Query<'q, DB, <DB as HasArguments<'q>>::Arguments>::bind,
>(
key: &str,
b: T,
) {
let statement = format!("update preferences set {} = $1 where key = 'p'", &key);
sqlx::query(&statement)
.bind(&b)
.execute(&pg)
.await
.unwrap();
}