refactor: simplify default implementation for Config struct

This commit is contained in:
2026-03-17 21:54:45 +01:00
parent 308867b2d9
commit 0c463703a3
2 changed files with 8 additions and 14 deletions

View File

@@ -126,18 +126,12 @@ impl Default for GeneralConfig {
} }
#[derive(Debug, Deserialize, Clone)] #[derive(Debug, Deserialize, Clone)]
#[derive(Default)]
pub struct Config { pub struct Config {
#[serde(default)] #[serde(default)]
pub general: GeneralConfig, pub general: GeneralConfig,
} }
impl Default for Config {
fn default() -> Self {
Self {
general: GeneralConfig::default(),
}
}
}
fn validate(config: Config) -> Result<Config, ConfigError> { fn validate(config: Config) -> Result<Config, ConfigError> {
if config.general.quality > 100 { if config.general.quality > 100 {

View File

@@ -152,14 +152,14 @@ fn percent_decode(s: &str) -> String {
let mut out = Vec::with_capacity(bytes.len()); let mut out = Vec::with_capacity(bytes.len());
let mut i = 0; let mut i = 0;
while i < bytes.len() { while i < bytes.len() {
if bytes[i] == b'%' && i + 2 < bytes.len() { if bytes[i] == b'%'
if let Ok(b) = && i + 2 < bytes.len()
&& let Ok(b) =
u8::from_str_radix(std::str::from_utf8(&bytes[i + 1..i + 3]).unwrap_or(""), 16) u8::from_str_radix(std::str::from_utf8(&bytes[i + 1..i + 3]).unwrap_or(""), 16)
{ {
out.push(b); out.push(b);
i += 3; i += 3;
continue; continue;
}
} }
out.push(bytes[i]); out.push(bytes[i]);
i += 1; i += 1;