Skip to content

Commit

Permalink
remove extra conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
yggverse committed Dec 3, 2024
1 parent f08ae77 commit b4d9686
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 27 deletions.
26 changes: 7 additions & 19 deletions src/line/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,15 @@ impl Header {
RegexMatchFlags::DEFAULT,
);

// Detect header level
let level = regex.get(1)?;

let level = match level.len() {
1 => Level::H1,
2 => Level::H2,
3 => Level::H3,
_ => return None,
};

// Detect header value
let value = regex.get(2)?.trim();

if value.is_empty() {
return None;
}

// Result
Some(Self {
level,
value: value.to_string(),
level: match regex.get(1)?.len() {
1 => Level::H1,
2 => Level::H2,
3 => Level::H3,
_ => return None,
},
value: regex.get(2)?.trim().to_string(),
})
}
}
7 changes: 3 additions & 4 deletions src/line/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ impl List {
);

// Extract formatted value
let value = regex.get(1)?.trim().to_string();

// Result
Some(Self { value })
Some(Self {
value: regex.get(1)?.trim().to_string(),
})
}
}
7 changes: 3 additions & 4 deletions src/line/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ impl Quote {
);

// Extract formatted value
let value = regex.get(1)?.trim().to_string();

// Result
Some(Self { value })
Some(Self {
value: regex.get(1)?.trim().to_string(),
})
}
}

0 comments on commit b4d9686

Please sign in to comment.