aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/thematic_break.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/construct/thematic_break.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/construct/thematic_break.rs b/src/construct/thematic_break.rs
index 8d29157..28aca34 100644
--- a/src/construct/thematic_break.rs
+++ b/src/construct/thematic_break.rs
@@ -95,7 +95,7 @@ impl Kind {
///
/// ## Panics
///
- /// Panics if `char` is not `*`, `_`, or `_`.
+ /// Panics if `char` is not `*`, `-`, or `_`.
fn from_char(char: char) -> Kind {
match char {
'*' => Kind::Asterisk,
@@ -104,6 +104,19 @@ impl Kind {
_ => unreachable!("invalid char"),
}
}
+ /// Turn [Code] into a kind.
+ ///
+ /// > 👉 **Note**: an opening paren must be used for `Kind::Paren`.
+ ///
+ /// ## Panics
+ ///
+ /// Panics if `code` is not `Code::Char('*' | '-' | '_')`.
+ fn from_code(code: Code) -> Kind {
+ match code {
+ Code::Char(char) => Kind::from_char(char),
+ _ => unreachable!("invalid code"),
+ }
+ }
}
/// State needed to parse thematic breaks.
@@ -133,11 +146,11 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
/// ```
fn before(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
match code {
- Code::Char(char) if char == '*' || char == '-' || char == '_' => at_break(
+ Code::Char('*' | '-' | '_') => at_break(
tokenizer,
code,
Info {
- kind: Kind::from_char(char),
+ kind: Kind::from_code(code),
size: 0,
},
),