diff options
Diffstat (limited to 'src/reader.rs')
-rw-r--r-- | src/reader.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/reader.rs b/src/reader.rs index eb2b479..6067c47 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -31,18 +31,18 @@ pub trait Reader { /// /// For example, any utf8-string can be converted into a `StringReader`, such that /// `Tokenizer::new("mystring")` and `Tokenizer::new(&String::new("foo"))` work. -pub trait Readable<'a> { - /// The reader type to which this type should be converted. +pub trait IntoReader<'a> { + /// The reader type into which this type should be converted. type Reader: Reader + 'a; - /// Convert self to some sort of reader. - fn to_reader(self) -> Self::Reader; + /// Convert self into some sort of reader. + fn into_reader(self) -> Self::Reader; } -impl<'a, R: 'a + Reader> Readable<'a> for R { +impl<'a, R: 'a + Reader> IntoReader<'a> for R { type Reader = Self; - fn to_reader(self) -> Self::Reader { + fn into_reader(self) -> Self::Reader { self } } @@ -120,18 +120,18 @@ impl<'a> Reader for StringReader<'a> { } } -impl<'a> Readable<'a> for &'a str { +impl<'a> IntoReader<'a> for &'a str { type Reader = StringReader<'a>; - fn to_reader(self) -> Self::Reader { + fn into_reader(self) -> Self::Reader { StringReader::new(self) } } -impl<'a> Readable<'a> for &'a String { +impl<'a> IntoReader<'a> for &'a String { type Reader = StringReader<'a>; - fn to_reader(self) -> Self::Reader { + fn into_reader(self) -> Self::Reader { StringReader::new(self.as_str()) } } @@ -225,10 +225,10 @@ impl<R: BufRead> Reader for BufReadReader<R> { } } -impl<'a, R: Read + 'a> Readable<'a> for BufReader<R> { +impl<'a, R: Read + 'a> IntoReader<'a> for BufReader<R> { type Reader = BufReadReader<BufReader<R>>; - fn to_reader(self) -> Self::Reader { + fn into_reader(self) -> Self::Reader { BufReadReader::new(self) } } |