Skip to content

Commit 7478753

Browse files
committed
Fix raw value compilation on rustc older than 1.20
1 parent e58102f commit 7478753

File tree

1 file changed

+40
-14
lines changed

1 file changed

+40
-14
lines changed

src/read.rs

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,20 @@ where
166166
{
167167
/// Create a JSON input source to read from a std::io input stream.
168168
pub fn new(reader: R) -> Self {
169-
IoRead {
170-
iter: LineColIterator::new(reader.bytes()),
171-
ch: None,
172-
#[cfg(feature = "raw_value")]
173-
raw_buffer: None,
169+
#[cfg(not(feature = "raw_value"))]
170+
{
171+
IoRead {
172+
iter: LineColIterator::new(reader.bytes()),
173+
ch: None,
174+
}
175+
}
176+
#[cfg(feature = "raw_value")]
177+
{
178+
IoRead {
179+
iter: LineColIterator::new(reader.bytes()),
180+
ch: None,
181+
raw_buffer: None,
182+
}
174183
}
175184
}
176185
}
@@ -351,11 +360,20 @@ where
351360
impl<'a> SliceRead<'a> {
352361
/// Create a JSON input source to read from a slice of bytes.
353362
pub fn new(slice: &'a [u8]) -> Self {
354-
SliceRead {
355-
slice: slice,
356-
index: 0,
357-
#[cfg(feature = "raw_value")]
358-
raw_buffering_start_index: 0,
363+
#[cfg(not(feature = "raw_value"))]
364+
{
365+
SliceRead {
366+
slice: slice,
367+
index: 0,
368+
}
369+
}
370+
#[cfg(feature = "raw_value")]
371+
{
372+
SliceRead {
373+
slice: slice,
374+
index: 0,
375+
raw_buffering_start_index: 0,
376+
}
359377
}
360378
}
361379

@@ -531,10 +549,18 @@ impl<'a> Read<'a> for SliceRead<'a> {
531549
impl<'a> StrRead<'a> {
532550
/// Create a JSON input source to read from a UTF-8 string.
533551
pub fn new(s: &'a str) -> Self {
534-
StrRead {
535-
delegate: SliceRead::new(s.as_bytes()),
536-
#[cfg(feature = "raw_value")]
537-
data: s,
552+
#[cfg(not(feature = "raw_value"))]
553+
{
554+
StrRead {
555+
delegate: SliceRead::new(s.as_bytes()),
556+
}
557+
}
558+
#[cfg(feature = "raw_value")]
559+
{
560+
StrRead {
561+
delegate: SliceRead::new(s.as_bytes()),
562+
data: s,
563+
}
538564
}
539565
}
540566
}

0 commit comments

Comments
 (0)