compilation fix
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use regex::Regex;
|
||||
use std::env::args;
|
||||
use std::{borrow::Cow, env::args};
|
||||
|
||||
fn main() {
|
||||
let path = args().nth(1).expect("usage: 1 image file argument");
|
||||
@@ -12,9 +12,9 @@ fn main() {
|
||||
println!(" D 0x{d:08x}");
|
||||
}
|
||||
}
|
||||
fn remove_non_alphanumeric(input: &str) -> String {
|
||||
fn remove_non_alphanumeric(input: &str) -> Cow<'_, str> {
|
||||
let re = Regex::new(r"[^a-zA-Z0-9_]+").unwrap();
|
||||
re.replace_all(input, "").to_string()
|
||||
re.replace_all(input, "")
|
||||
}
|
||||
|
||||
fn path_to_img(path: &str) -> (Vec<u32>, String, u32, u32) {
|
||||
@@ -48,6 +48,9 @@ fn path_to_img(path: &str) -> (Vec<u32>, String, u32, u32) {
|
||||
}
|
||||
let path = path.split('/').next_back().unwrap();
|
||||
let split: Vec<_> = path.split('.').collect();
|
||||
let name = remove_non_alphanumeric(&split[0..split.len() - 1].join("_")).to_lowercase();
|
||||
let name = format!(
|
||||
"picture_{}",
|
||||
remove_non_alphanumeric(&split[0..split.len() - 1].join("_")).to_lowercase()
|
||||
);
|
||||
(bytes, name, width, height)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user