Skip to content

Commit 1a2ccba

Browse files
committed
Drop superfluous tuple returns
1 parent b1d9071 commit 1a2ccba

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

src/parse.rs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ fn is_whitespace(ch: char) -> bool {
150150
ch.is_whitespace() || ch == '\u{200e}' || ch == '\u{200f}'
151151
}
152152

153-
fn word_break(input: Cursor) -> PResult<()> {
153+
fn word_break(input: Cursor) -> Result<Cursor, LexError> {
154154
match input.chars().next() {
155155
Some(ch) if UnicodeXID::is_xid_continue(ch) => Err(LexError),
156-
Some(_) | None => Ok((input, ())),
156+
Some(_) | None => Ok(input),
157157
}
158158
}
159159

@@ -276,15 +276,15 @@ fn symbol_not_raw(input: Cursor) -> PResult<&str> {
276276

277277
fn literal(input: Cursor) -> PResult<Literal> {
278278
match literal_nocapture(input) {
279-
Ok((a, ())) => {
279+
Ok(a) => {
280280
let end = input.len() - a.len();
281281
Ok((a, Literal::_new(input.rest[..end].to_string())))
282282
}
283283
Err(LexError) => Err(LexError),
284284
}
285285
}
286286

287-
fn literal_nocapture(input: Cursor) -> PResult<()> {
287+
fn literal_nocapture(input: Cursor) -> Result<Cursor, LexError> {
288288
if let Ok(ok) = string(input) {
289289
Ok(ok)
290290
} else if let Ok(ok) = byte_string(input) {
@@ -302,13 +302,13 @@ fn literal_nocapture(input: Cursor) -> PResult<()> {
302302
}
303303
}
304304

305-
fn string(input: Cursor) -> PResult<()> {
305+
fn string(input: Cursor) -> Result<Cursor, LexError> {
306306
if let Ok(input) = input.expect("\"") {
307-
let (input, ()) = cooked_string(input)?;
307+
let input = cooked_string(input)?;
308308
let input = input.expect("\"")?;
309309
match symbol_not_raw(input) {
310-
Ok((input, _)) => Ok((input, ())),
311-
Err(LexError) => Ok((input, ())),
310+
Ok((input, _)) => Ok(input),
311+
Err(LexError) => Ok(input),
312312
}
313313
} else if let Ok(input) = input.expect("r") {
314314
raw_string(input)
@@ -317,12 +317,12 @@ fn string(input: Cursor) -> PResult<()> {
317317
}
318318
}
319319

320-
fn cooked_string(input: Cursor) -> PResult<()> {
320+
fn cooked_string(input: Cursor) -> Result<Cursor, LexError> {
321321
let mut chars = input.char_indices().peekable();
322322
while let Some((byte_offset, ch)) = chars.next() {
323323
match ch {
324324
'"' => {
325-
return Ok((input.advance(byte_offset), ()));
325+
return Ok(input.advance(byte_offset));
326326
}
327327
'\r' => {
328328
if let Some((_, '\n')) = chars.next() {
@@ -361,25 +361,25 @@ fn cooked_string(input: Cursor) -> PResult<()> {
361361
Err(LexError)
362362
}
363363

364-
fn byte_string(input: Cursor) -> PResult<()> {
364+
fn byte_string(input: Cursor) -> Result<Cursor, LexError> {
365365
if let Ok(input) = input.expect("b\"") {
366-
let (input, ()) = cooked_byte_string(input)?;
366+
let input = cooked_byte_string(input)?;
367367
let input = input.expect("\"")?;
368-
Ok((input, ()))
368+
Ok(input)
369369
} else if let Ok(input) = input.expect("br") {
370-
let (input, ()) = raw_string(input)?;
371-
Ok((input, ()))
370+
let input = raw_string(input)?;
371+
Ok(input)
372372
} else {
373373
Err(LexError)
374374
}
375375
}
376376

377-
fn cooked_byte_string(mut input: Cursor) -> PResult<()> {
377+
fn cooked_byte_string(mut input: Cursor) -> Result<Cursor, LexError> {
378378
let mut bytes = input.bytes().enumerate();
379379
'outer: while let Some((offset, b)) = bytes.next() {
380380
match b {
381381
b'"' => {
382-
return Ok((input.advance(offset), ()));
382+
return Ok(input.advance(offset));
383383
}
384384
b'\r' => {
385385
if let Some((_, b'\n')) = bytes.next() {
@@ -416,7 +416,7 @@ fn cooked_byte_string(mut input: Cursor) -> PResult<()> {
416416
Err(LexError)
417417
}
418418

419-
fn raw_string(input: Cursor) -> PResult<()> {
419+
fn raw_string(input: Cursor) -> Result<Cursor, LexError> {
420420
let mut chars = input.char_indices();
421421
let mut n = 0;
422422
while let Some((byte_offset, ch)) = chars.next() {
@@ -433,7 +433,7 @@ fn raw_string(input: Cursor) -> PResult<()> {
433433
match ch {
434434
'"' if input.advance(byte_offset + 1).starts_with(&input.rest[..n]) => {
435435
let rest = input.advance(byte_offset + 1 + n);
436-
return Ok((rest, ()));
436+
return Ok(rest);
437437
}
438438
'\r' => {}
439439
_ => {}
@@ -442,14 +442,14 @@ fn raw_string(input: Cursor) -> PResult<()> {
442442
Err(LexError)
443443
}
444444

445-
fn byte(input: Cursor) -> PResult<()> {
445+
fn byte(input: Cursor) -> Result<Cursor, LexError> {
446446
let input = input.expect("b'")?;
447-
let (input, ()) = cooked_byte(input)?;
447+
let input = cooked_byte(input)?;
448448
let input = input.expect("'")?;
449-
Ok((input, ()))
449+
Ok(input)
450450
}
451451

452-
fn cooked_byte(input: Cursor) -> PResult<()> {
452+
fn cooked_byte(input: Cursor) -> Result<Cursor, LexError> {
453453
let mut bytes = input.bytes().enumerate();
454454
let ok = match bytes.next().map(|(_, b)| b) {
455455
Some(b'\\') => match bytes.next().map(|(_, b)| b) {
@@ -464,26 +464,26 @@ fn cooked_byte(input: Cursor) -> PResult<()> {
464464
match bytes.next() {
465465
Some((offset, _)) => {
466466
if input.chars().as_str().is_char_boundary(offset) {
467-
Ok((input.advance(offset), ()))
467+
Ok(input.advance(offset))
468468
} else {
469469
Err(LexError)
470470
}
471471
}
472-
None => Ok((input.advance(input.len()), ())),
472+
None => Ok(input.advance(input.len())),
473473
}
474474
} else {
475475
Err(LexError)
476476
}
477477
}
478478

479-
fn character(input: Cursor) -> PResult<()> {
479+
fn character(input: Cursor) -> Result<Cursor, LexError> {
480480
let input = input.expect("'")?;
481-
let (input, ()) = cooked_char(input)?;
481+
let input = cooked_char(input)?;
482482
let input = input.expect("'")?;
483-
Ok((input, ()))
483+
Ok(input)
484484
}
485485

486-
fn cooked_char(input: Cursor) -> PResult<()> {
486+
fn cooked_char(input: Cursor) -> Result<Cursor, LexError> {
487487
let mut chars = input.char_indices();
488488
let ok = match chars.next().map(|(_, ch)| ch) {
489489
Some('\\') => match chars.next().map(|(_, ch)| ch) {
@@ -498,8 +498,8 @@ fn cooked_char(input: Cursor) -> PResult<()> {
498498
};
499499
if ok {
500500
match chars.next() {
501-
Some((idx, _)) => Ok((input.advance(idx), ())),
502-
None => Ok((input.advance(input.len()), ())),
501+
Some((idx, _)) => Ok(input.advance(idx)),
502+
None => Ok(input.advance(input.len())),
503503
}
504504
} else {
505505
Err(LexError)
@@ -550,8 +550,8 @@ where
550550
}
551551
}
552552

553-
fn float(input: Cursor) -> PResult<()> {
554-
let (mut rest, ()) = float_digits(input)?;
553+
fn float(input: Cursor) -> Result<Cursor, LexError> {
554+
let mut rest = float_digits(input)?;
555555
if let Some(ch) = rest.chars().next() {
556556
if is_ident_start(ch) {
557557
rest = symbol_not_raw(rest)?.0;
@@ -560,7 +560,7 @@ fn float(input: Cursor) -> PResult<()> {
560560
word_break(rest)
561561
}
562562

563-
fn float_digits(input: Cursor) -> PResult<()> {
563+
fn float_digits(input: Cursor) -> Result<Cursor, LexError> {
564564
let mut chars = input.chars().peekable();
565565
match chars.next() {
566566
Some(ch) if ch >= '0' && ch <= '9' => {}
@@ -634,11 +634,11 @@ fn float_digits(input: Cursor) -> PResult<()> {
634634
}
635635
}
636636

637-
Ok((input.advance(len), ()))
637+
Ok(input.advance(len))
638638
}
639639

640-
fn int(input: Cursor) -> PResult<()> {
641-
let (mut rest, ()) = digits(input)?;
640+
fn int(input: Cursor) -> Result<Cursor, LexError> {
641+
let mut rest = digits(input)?;
642642
if let Some(ch) = rest.chars().next() {
643643
if is_ident_start(ch) {
644644
rest = symbol_not_raw(rest)?.0;
@@ -647,7 +647,7 @@ fn int(input: Cursor) -> PResult<()> {
647647
word_break(rest)
648648
}
649649

650-
fn digits(mut input: Cursor) -> PResult<()> {
650+
fn digits(mut input: Cursor) -> Result<Cursor, LexError> {
651651
let base = if input.starts_with("0x") {
652652
input = input.advance(2);
653653
16
@@ -686,7 +686,7 @@ fn digits(mut input: Cursor) -> PResult<()> {
686686
if empty {
687687
Err(LexError)
688688
} else {
689-
Ok((input.advance(len), ()))
689+
Ok(input.advance(len))
690690
}
691691
}
692692

0 commit comments

Comments
 (0)