Skip to content

Commit 4077ffd

Browse files
bors[bot]CAD97
andauthored
Merge #225
225: Fix #174 r=kvark a=CAD97 Disclaimer: untested; just applies the patch recommended by @torkleyy in #174. Closes #174. Co-authored-by: Christopher Durham <[email protected]>
2 parents c6873c6 + 02e3d17 commit 4077ffd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/ser/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl Serializer {
224224

225225
fn is_pretty(&self) -> bool {
226226
match self.pretty {
227-
Some((ref config, ref pretty)) => pretty.indent < config.depth_limit,
227+
Some((ref config, ref pretty)) => pretty.indent <= config.depth_limit,
228228
None => false,
229229
}
230230
}
@@ -244,7 +244,7 @@ impl Serializer {
244244
fn start_indent(&mut self) {
245245
if let Some((ref config, ref mut pretty)) = self.pretty {
246246
pretty.indent += 1;
247-
if pretty.indent < config.depth_limit {
247+
if pretty.indent <= config.depth_limit {
248248
let is_empty = self.is_empty.unwrap_or(false);
249249

250250
if !is_empty {
@@ -256,7 +256,7 @@ impl Serializer {
256256

257257
fn indent(&mut self) {
258258
if let Some((ref config, ref pretty)) = self.pretty {
259-
if pretty.indent < config.depth_limit {
259+
if pretty.indent <= config.depth_limit {
260260
self.output
261261
.extend((0..pretty.indent).map(|_| config.indentor.as_str()));
262262
}
@@ -265,7 +265,7 @@ impl Serializer {
265265

266266
fn end_indent(&mut self) {
267267
if let Some((ref config, ref mut pretty)) = self.pretty {
268-
if pretty.indent < config.depth_limit {
268+
if pretty.indent <= config.depth_limit {
269269
let is_empty = self.is_empty.unwrap_or(false);
270270

271271
if !is_empty {
@@ -567,7 +567,7 @@ impl<'a> ser::SerializeSeq for &'a mut Serializer {
567567
self.output += ",";
568568

569569
if let Some((ref config, ref mut pretty)) = self.pretty {
570-
if pretty.indent < config.depth_limit {
570+
if pretty.indent <= config.depth_limit {
571571
if config.enumerate_arrays {
572572
assert!(config.new_line.contains('\n'));
573573
let index = pretty.sequence_index.last_mut().unwrap();
@@ -611,7 +611,7 @@ impl<'a> ser::SerializeTuple for &'a mut Serializer {
611611
self.output += ",";
612612

613613
if let Some((ref config, ref pretty)) = self.pretty {
614-
if pretty.indent < config.depth_limit {
614+
if pretty.indent <= config.depth_limit {
615615
self.output += if self.separate_tuple_members() {
616616
&config.new_line
617617
} else {
@@ -697,7 +697,7 @@ impl<'a> ser::SerializeMap for &'a mut Serializer {
697697
self.output += ",";
698698

699699
if let Some((ref config, ref pretty)) = self.pretty {
700-
if pretty.indent < config.depth_limit {
700+
if pretty.indent <= config.depth_limit {
701701
self.output += &config.new_line;
702702
}
703703
}
@@ -734,7 +734,7 @@ impl<'a> ser::SerializeStruct for &'a mut Serializer {
734734
self.output += ",";
735735

736736
if let Some((ref config, ref pretty)) = self.pretty {
737-
if pretty.indent < config.depth_limit {
737+
if pretty.indent <= config.depth_limit {
738738
self.output += &config.new_line;
739739
}
740740
}

0 commit comments

Comments
 (0)