Skip to content

Commit

Permalink
Pass char when checking for single character starts_with
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Apr 1, 2023
1 parent b539d5a commit 287979f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ impl<'a> Cursor<'a> {
self.rest.starts_with(s)
}

fn starts_with_char(&self, ch: char) -> bool {
self.rest.starts_with(ch)
}

fn is_empty(&self) -> bool {
self.rest.is_empty()
}
Expand Down Expand Up @@ -756,7 +760,7 @@ fn digits(mut input: Cursor) -> Result<Cursor, Reject> {
fn punct(input: Cursor) -> PResult<Punct> {
let (rest, ch) = punct_char(input)?;
if ch == '\'' {
if ident_any(rest)?.0.starts_with("'") {
if ident_any(rest)?.0.starts_with_char('\'') {
Err(Reject)
} else {
Ok((rest, Punct::new('\'', Spacing::Joint)))
Expand Down Expand Up @@ -848,7 +852,7 @@ fn doc_comment_contents(input: Cursor) -> PResult<(&str, bool)> {
Ok((input, (&s[3..s.len() - 2], true)))
} else if input.starts_with("///") {
let input = input.advance(3);
if input.starts_with("/") {
if input.starts_with_char('/') {
return Err(Reject);
}
let (input, s) = take_until_newline_or_eof(input);
Expand Down

0 comments on commit 287979f

Please sign in to comment.