more clippy

This commit is contained in:
Christien Rioux
2023-09-18 19:49:57 -04:00
parent f596b3ce05
commit 20451af880
18 changed files with 115 additions and 122 deletions

View File

@@ -6,7 +6,7 @@ cfg_if! {
pub fn get_timestamp() -> u64 {
if is_browser() {
return (Date::now() * 1000.0f64) as u64;
(Date::now() * 1000.0f64) as u64
} else {
panic!("WASM requires browser environment");
}
@@ -23,28 +23,34 @@ cfg_if! {
let show_month = show_year || now.get_utc_month() != date.get_utc_month();
let show_date = show_month || now.get_utc_date() != date.get_utc_date();
let s_year = if show_year {
format!("{:04}/",date.get_utc_full_year())
} else {
"".to_owned()
};
let s_month = if show_month {
format!("{:02}/",date.get_utc_month())
} else {
"".to_owned()
};
let s_date = if show_date {
format!("{:02}-",date.get_utc_date())
} else {
"".to_owned()
};
let s_time = format!("{:02}:{:02}:{:02}.{:04}",
date.get_utc_hours(),
date.get_utc_minutes(),
date.get_utc_seconds(),
date.get_utc_milliseconds()
);
format!("{}{}{}{}",
if show_year {
format!("{:04}/",date.get_utc_full_year())
} else {
"".to_owned()
},
if show_month {
format!("{:02}/",date.get_utc_month())
} else {
"".to_owned()
},
if show_date {
format!("{:02}-",date.get_utc_date())
} else {
"".to_owned()
},
format!("{:02}:{:02}:{:02}.{:04}",
date.get_utc_hours(),
date.get_utc_minutes(),
date.get_utc_seconds(),
date.get_utc_milliseconds()
))
s_year,
s_month,
s_date,
s_time
)
} else {
panic!("WASM requires browser environment");
}

View File

@@ -21,7 +21,7 @@ pub fn is_browser() -> bool {
return cache != 0;
}
let res = Reflect::has(&global().as_ref(), &"navigator".into()).unwrap_or_default();
let res = Reflect::has(global().as_ref(), &"navigator".into()).unwrap_or_default();
CACHE.store(res as i8, Ordering::Relaxed);
@@ -45,7 +45,7 @@ pub fn is_browser_https() -> bool {
}
pub fn get_wasm_global_string_value<K: AsRef<str>>(key: K) -> Option<String> {
let Ok(v) = Reflect::get(&global().as_ref(), &JsValue::from_str(key.as_ref())) else {
let Ok(v) = Reflect::get(global().as_ref(), &JsValue::from_str(key.as_ref())) else {
return None;
};
v.as_string()