From f78a7ade61c1c218eead76854abb7d83bb6c6f75 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Sun, 4 Oct 2020 17:07:30 +0000 Subject: [PATCH] Inline "eof" methods --- library/std/src/net/parser.rs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/library/std/src/net/parser.rs b/library/std/src/net/parser.rs index da94a573503..3a5fd8f6f5d 100644 --- a/library/std/src/net/parser.rs +++ b/library/std/src/net/parser.rs @@ -44,10 +44,6 @@ impl<'a> Parser<'a> { Parser { state: input.as_bytes() } } - fn is_eof(&self) -> bool { - self.state.is_empty() - } - /// Run a parser, and restore the pre-parse state if it fails fn read_atomically(&mut self, inner: F) -> Option where @@ -63,19 +59,12 @@ impl<'a> Parser<'a> { /// Run a parser, but fail if the entire input wasn't consumed. /// Doesn't run atomically. - fn read_till_eof(&mut self, inner: F) -> Option - where - F: FnOnce(&mut Parser<'_>) -> Option, - { - inner(self).filter(|_| self.is_eof()) - } - - /// Same as read_till_eof, but returns a Result on failure fn parse_with(&mut self, inner: F) -> Result where F: FnOnce(&mut Parser<'_>) -> Option, { - self.read_till_eof(inner).ok_or(AddrParseError(())) + let result = inner(self); + if self.state.is_empty() { result } else { None }.ok_or(AddrParseError(())) } /// Read the next character from the input