summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md4
-rw-r--r--src/reader.rs16
2 files changed, 20 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e2613cd..03652cd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
### [unreleased]
+#### Features
+
+* Added a blanket implementation to implement `Reader` for boxed readers.
+
#### Breaking changes
* `Emitter` trait
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> {