chore (backend-rs): prefer using as_ref & apply clippy fix

This commit is contained in:
naskya 2024-06-15 07:03:52 +09:00
parent 93fdf11cfa
commit 9d9af28cb1
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C

View file

@ -27,11 +27,11 @@ fn init_id_generator(length: u8, fingerprint: &str) {
/// It automatically calls [init_id_generator], if the generator has not been initialized. /// It automatically calls [init_id_generator], if the generator has not been initialized.
fn create_id(datetime: &NaiveDateTime) -> String { fn create_id(datetime: &NaiveDateTime) -> String {
if GENERATOR.get().is_none() { if GENERATOR.get().is_none() {
let length = match &CONFIG.cuid { let length = match CONFIG.cuid.as_ref() {
Some(cuid) => cmp::min(cmp::max(cuid.length.unwrap_or(16), 16), 24), Some(cuid) => cuid.length.unwrap_or(16).clamp(16, 24),
None => 16, None => 16,
}; };
let fingerprint = match &CONFIG.cuid { let fingerprint = match CONFIG.cuid.as_ref() {
Some(cuid) => cuid.fingerprint.as_deref().unwrap_or_default(), Some(cuid) => cuid.fingerprint.as_deref().unwrap_or_default(),
None => "", None => "",
}; };