diff options
author | Martin Fischer <martin@push-f.com> | 2023-09-04 08:28:11 +0200 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2023-09-28 07:26:44 +0200 |
commit | 1e746e68f647eb42586ffab81fefa9f68723ed97 (patch) | |
tree | 12f5f004a4726729fa6ca85bfddc99c49d51929a /src | |
parent | 9dd2ac1c95c949066e341837650c3211769342c3 (diff) |
feat: add blanket impl of Reader for boxed readers
Diffstat (limited to 'src')
-rw-r--r-- | src/reader.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/reader.rs b/src/reader.rs index 3c39b16..7038847 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -55,6 +55,22 @@ impl<'a, R: 'a + Reader> IntoReader<'a> for R { } } +impl<R: Reader + ?Sized> Reader for Box<R> { + type Error = R::Error; + + fn read_char(&mut self) -> Result<Option<char>, Self::Error> { + self.as_mut().read_char() + } + + fn try_read_string(&mut self, s: &str, case_sensitive: bool) -> Result<bool, Self::Error> { + self.as_mut().try_read_string(s, case_sensitive) + } + + fn len_of_char_in_current_encoding(&self, c: char) -> usize { + self.as_ref().len_of_char_in_current_encoding(c) + } +} + /// A helper struct to seek forwards and backwards in strings. Used by the tokenizer to read HTML /// from strings. pub struct StringReader<'a> { |