Skip to content

Commit f78a7ad

Browse files
committed
Inline "eof" methods
1 parent 9601724 commit f78a7ad

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

library/std/src/net/parser.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ impl<'a> Parser<'a> {
4444
Parser { state: input.as_bytes() }
4545
}
4646

47-
fn is_eof(&self) -> bool {
48-
self.state.is_empty()
49-
}
50-
5147
/// Run a parser, and restore the pre-parse state if it fails
5248
fn read_atomically<T, F>(&mut self, inner: F) -> Option<T>
5349
where
@@ -63,19 +59,12 @@ impl<'a> Parser<'a> {
6359

6460
/// Run a parser, but fail if the entire input wasn't consumed.
6561
/// Doesn't run atomically.
66-
fn read_till_eof<T, F>(&mut self, inner: F) -> Option<T>
67-
where
68-
F: FnOnce(&mut Parser<'_>) -> Option<T>,
69-
{
70-
inner(self).filter(|_| self.is_eof())
71-
}
72-
73-
/// Same as read_till_eof, but returns a Result<AddrParseError> on failure
7462
fn parse_with<T, F>(&mut self, inner: F) -> Result<T, AddrParseError>
7563
where
7664
F: FnOnce(&mut Parser<'_>) -> Option<T>,
7765
{
78-
self.read_till_eof(inner).ok_or(AddrParseError(()))
66+
let result = inner(self);
67+
if self.state.is_empty() { result } else { None }.ok_or(AddrParseError(()))
7968
}
8069

8170
/// Read the next character from the input

0 commit comments

Comments
 (0)