treewide: move some code around, spring cleaning

This commit is contained in:
2024-08-07 20:50:39 +02:00
parent 833251a1a2
commit 71c712dce0
9 changed files with 467 additions and 432 deletions

View File

@@ -161,3 +161,24 @@ pub fn quote_literal(s: &str) -> String {
pub fn quote_identifier(s: &str) -> String {
format!("`{}`", s.replace('`', r"\`"))
}
#[inline]
pub(crate) fn yn(b: bool) -> &'static str {
if b {
"Y"
} else {
"N"
}
}
#[inline]
pub(crate) fn rev_yn(s: &str) -> bool {
match s.to_lowercase().as_str() {
"y" => true,
"n" => false,
_ => {
log::warn!("Invalid value for privilege: {}", s);
false
}
}
}