Skip to content

Commit 8c2d800

Browse files
Add more warnings to apply buffering on docs of affected functions
1 parent 65bbd1a commit 8c2d800

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/de.rs

+6
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,17 @@ where
4545
/// Create a JSON deserializer from one of the possible serde_json input
4646
/// sources.
4747
///
48+
/// When reading from a source against which short reads are not efficient, such
49+
/// as a [`File`], you will want to apply your own buffering because serde_json
50+
/// will not buffer the input. See [`std::io::BufReader`].
51+
///
4852
/// Typically it is more convenient to use one of these methods instead:
4953
///
5054
/// - Deserializer::from_str
5155
/// - Deserializer::from_slice
5256
/// - Deserializer::from_reader
57+
///
58+
/// [`File`]: https://doc.rust-lang.org/std/fs/struct.File.html
5359
pub fn new(read: R) -> Self {
5460
Deserializer {
5561
read,

src/read.rs

+6
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ where
191191
R: io::Read,
192192
{
193193
/// Create a JSON input source to read from a std::io input stream.
194+
///
195+
/// When reading from a source against which short reads are not efficient, such
196+
/// as a [`File`], you will want to apply your own buffering because serde_json
197+
/// will not buffer the input. See [`std::io::BufReader`].
198+
///
199+
/// [`File`]: https://doc.rust-lang.org/std/fs/struct.File.html
194200
pub fn new(reader: R) -> Self {
195201
IoRead {
196202
iter: LineColIterator::new(reader.bytes()),

0 commit comments

Comments
 (0)