Use then() instead of ifs and Somes
parent
bbf120f753
commit
4f4764705d
|
@ -45,13 +45,7 @@ pub fn parse(text: &'_ str) -> Vec<DiscordComponent<'_>> {
|
|||
|
||||
pub fn parse_token(text: &'_ str, is_line_start: bool) -> Option<(DiscordComponent<'_>, usize)> {
|
||||
parse_escaped_literal(text)
|
||||
.or_else(|| {
|
||||
if is_line_start {
|
||||
parse_quotes(text)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.or_else(|| is_line_start.then(|| parse_quotes(text)).flatten())
|
||||
.or_else(|| parse_code_block(text))
|
||||
.or_else(|| parse_code(text))
|
||||
.or_else(|| parse_link(text))
|
||||
|
@ -79,9 +73,6 @@ pub fn parse_escaped_literal(text: &'_ str) -> Option<(DiscordComponent<'_>, usi
|
|||
}
|
||||
|
||||
pub fn parse_line_break(text: &'_ str) -> Option<(DiscordComponent<'_>, usize)> {
|
||||
if text.starts_with('\n') {
|
||||
return Some((DiscordComponent::LineBreak, 1));
|
||||
}
|
||||
|
||||
None
|
||||
text.starts_with('\n')
|
||||
.then(|| (DiscordComponent::LineBreak, 1))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue