This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Description
This is ugly
let mut fields =
String::from(r#""firstname" = $1, "lastname" = $2, "email" = $3"#);
let mut params: Vec<&(dyn ToSql + Sync)> =
vec![firstname, lastname, &email];
let hashed_password;
if let Some(password) = password {
hashed_password = hash(password, 12)?;
fields.push_str(r#", "password" = $4"#);
params.push(&hashed_password);
}
let raw_rights;
if let Some(rights) = rights {
raw_rights = RawRights(rights.clone());
fields.push_str(format!(r#", "rights" = {}"#, params.len() + 1));
params.push(&raw_rights);
}
let sql = format!(
"UPDATE \"{}\" SET {} WHERE \"id\" = ${}",
self.table.name(),
fields,
params.len() + 1
);
params.push(id);