mirror of
https://git.sr.ht/~spicywolf/k2spice
synced 2025-01-18 17:59:39 +00:00
pass clippy
This commit is contained in:
parent
6f88870051
commit
80b2dd3153
|
@ -71,54 +71,23 @@ fn escape(escstr: String) -> String {
|
||||||
im.clone()
|
im.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
fn fmtint(_s: &str, d: Option<String>) -> String {
|
||||||
* fn fmt(fmtstr: String, args: Vec<String>) -> String {
|
|
||||||
* let mut formatted: String = "".to_string();
|
|
||||||
* let mut data = args.into_iter();
|
|
||||||
* let fmtiter = fmtstr.clone();
|
|
||||||
* let mut fmtiter = fmtiter.chars().peekable();
|
|
||||||
* for _idx in 1..fmtstr.len() {
|
|
||||||
* let c: Option<char> = fmtiter.next();
|
|
||||||
* match c {
|
|
||||||
* Some('%') => {
|
|
||||||
* let next: char = if let Some(v) = fmtiter.next() {
|
|
||||||
* v
|
|
||||||
* } else {
|
|
||||||
* formatted += String::from('%').as_str();
|
|
||||||
* break;
|
|
||||||
* };
|
|
||||||
* match next {
|
|
||||||
* 'd' => {
|
|
||||||
* if let Some(arg) = data.next() {
|
|
||||||
* if let Ok(i) = arg.parse::<i64>() {
|
|
||||||
* formatted += String::from(format!("{i}")).as_str();
|
|
||||||
* } else {
|
|
||||||
* eprintln!("printf: trying to format non-int data as int");
|
|
||||||
* }
|
|
||||||
* } else {
|
|
||||||
* eprintln!("printf: format argument not supplied");
|
|
||||||
* }
|
|
||||||
* },
|
|
||||||
* _ => formatted += {String::from('%') + String::from(next).as_str()}.as_str(),
|
|
||||||
* }
|
|
||||||
* },
|
|
||||||
* Some(c) => formatted += String::from(c).as_str(),
|
|
||||||
* None => break,
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* formatted.clone()
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
|
|
||||||
fn fmtint(s: &str, d: Option<String>) -> String {
|
|
||||||
if let Some(i) = d {
|
if let Some(i) = d {
|
||||||
format!("{i}")
|
i.to_string()
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
String::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn chkfmt(chkstr: &str) -> bool {
|
fn fmtuint(_s: &str, d: Option<String>) -> String {
|
||||||
|
if let Some(i) = d {
|
||||||
|
i.to_string()
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn chkfmt(_chkstr: &str) -> bool {
|
||||||
// TODO: check if the thing is correct
|
// TODO: check if the thing is correct
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -130,7 +99,7 @@ fn fmt(fmtstr: String, args: Vec<String>) -> String {
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
while i < fmtb.len() {
|
while i < fmtb.len() {
|
||||||
if fmtb[i] == b'%' {
|
if fmtb[i] == b'%' {
|
||||||
if !(i + 1 >= fmtb.len()) {
|
if i + 1 < fmtb.len() {
|
||||||
let mut xe = i + 1;
|
let mut xe = i + 1;
|
||||||
// find end of format specifier and get its index
|
// find end of format specifier and get its index
|
||||||
while xe < fmtb.len() {
|
while xe < fmtb.len() {
|
||||||
|
@ -147,6 +116,7 @@ fn fmt(fmtstr: String, args: Vec<String>) -> String {
|
||||||
}
|
}
|
||||||
match fmtb[xe] {
|
match fmtb[xe] {
|
||||||
b'd' => formatted += fmtint(&fmtstr[i..xe], args.next()).as_str(),
|
b'd' => formatted += fmtint(&fmtstr[i..xe], args.next()).as_str(),
|
||||||
|
b'u' => formatted += fmtuint(&fmtstr[i..xe], args.next()).as_str(),
|
||||||
// at this point, this match should be impossible
|
// at this point, this match should be impossible
|
||||||
_ => (),
|
_ => (),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue