Skip to content

Commit

Permalink
fix: fix engine clap
Browse files Browse the repository at this point in the history
Signed-off-by: MrCroxx <[email protected]>
  • Loading branch information
MrCroxx committed Sep 23, 2024
1 parent cf57553 commit 3c4bb11
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions foyer-storage/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,16 @@ impl FromStr for Engine {
type Err = String;

fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
const MIXED_PREFIX: &str = "mixed(";
const MIXED_SUFFIX: &str = ")";
const MIXED_PREFIX: &str = "mixed=";

match s {
"large" => return Ok(Engine::Large),
"small" => return Ok(Engine::Small),
_ => {}
}

if s.starts_with(MIXED_PREFIX) && s.ends_with(MIXED_SUFFIX) {
if let Ok(ratio) = s[MIXED_PREFIX.len()..s.len() - MIXED_SUFFIX.len()].parse::<f64>() {
if s.starts_with(MIXED_PREFIX) {
if let Ok(ratio) = s[MIXED_PREFIX.len()..s.len()].parse::<f64>() {
return Ok(Engine::Mixed(ratio));
}
}
Expand Down

0 comments on commit 3c4bb11

Please sign in to comment.