diff options
| author | Thomas Voss <mail@thomasvoss.com> | 2026-03-04 01:34:59 +0100 |
|---|---|---|
| committer | Thomas Voss <mail@thomasvoss.com> | 2026-03-04 01:34:59 +0100 |
| commit | 5a3bb38d18da212d0ad18e406a602bf99e7631ee (patch) | |
| tree | 383055e0ecfe313869fd16f618321ce98dbd3518 /oryxc | |
| parent | 16bf53da8c17dbf231fe3e4077ac873fbedc8ee9 (diff) | |
Minor style changes
Diffstat (limited to 'oryxc')
| -rw-r--r-- | oryxc/src/errors.rs | 14 | ||||
| -rw-r--r-- | oryxc/src/lexer.rs | 17 |
2 files changed, 16 insertions, 15 deletions
diff --git a/oryxc/src/errors.rs b/oryxc/src/errors.rs index 3c00220..e1f72cd 100644 --- a/oryxc/src/errors.rs +++ b/oryxc/src/errors.rs @@ -132,9 +132,10 @@ impl OryxError { let errmid = new_string_with_spaces(&buffer[spanbeg..spanend]); let errend = new_string_with_spaces(&buffer[spanend..lineend]); - let errmid = match errmid.len() { - 0 => "_".to_string(), - _ => errmid, + let errmid = if errmid.len() == 0 { + "_".to_string() + } else { + errmid }; /* TODO: Do tab math */ @@ -180,9 +181,10 @@ fn new_string_with_spaces(s: &str) -> String { let ntabs = s.bytes().filter(|b| *b == b'\t').count(); let mut buf = String::with_capacity(s.len() + ntabs * (TABSIZE - 1)); for c in s.chars() { - match c { - '\t' => buf.push_str(TAB_AS_SPACES), - _ => buf.push(c), + if c == '\t' { + buf.push_str(TAB_AS_SPACES); + } else { + buf.push(c); } } return buf; diff --git a/oryxc/src/lexer.rs b/oryxc/src/lexer.rs index c82cd2c..09e2881 100644 --- a/oryxc/src/lexer.rs +++ b/oryxc/src/lexer.rs @@ -437,15 +437,14 @@ fn tokenize_string<'a>(ctx: &mut LexerContext<'a>) -> Result<Token, OryxError> { let i = ctx.pos_b; loop { - match ctx.next() { - Some(c) if c == '"' => break, - Some(_) => {}, - None => { - return Err(OryxError::new( - (i, ctx.pos_a), - "unterminated string literal", - )); - }, + let Some(c) = ctx.next() else { + return Err(OryxError::new( + (i, ctx.pos_a), + "unterminated string literal", + )); + }; + if c == '"' { + break; } } return Ok(Token { |