Skip to content

Commit

Permalink
Try #225:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored May 3, 2020
2 parents b657af9 + d26f019 commit 068c6f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl Serializer {

fn is_pretty(&self) -> bool {
match self.pretty {
Some((ref config, ref pretty)) => pretty.indent < config.depth_limit,
Some((ref config, ref pretty)) => pretty.indent <= config.depth_limit,
None => false,
}
}
Expand All @@ -244,7 +244,7 @@ impl Serializer {
fn start_indent(&mut self) {
if let Some((ref config, ref mut pretty)) = self.pretty {
pretty.indent += 1;
if pretty.indent < config.depth_limit {
if pretty.indent <= config.depth_limit {
let is_empty = self.is_empty.unwrap_or(false);

if !is_empty {
Expand All @@ -256,7 +256,7 @@ impl Serializer {

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

fn end_indent(&mut self) {
if let Some((ref config, ref mut pretty)) = self.pretty {
if pretty.indent < config.depth_limit {
if pretty.indent <= config.depth_limit {
let is_empty = self.is_empty.unwrap_or(false);

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

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

if let Some((ref config, ref pretty)) = self.pretty {
if pretty.indent < config.depth_limit {
if pretty.indent <= config.depth_limit {
self.output += if self.separate_tuple_members() {
&config.new_line
} else {
Expand Down Expand Up @@ -697,7 +697,7 @@ impl<'a> ser::SerializeMap for &'a mut Serializer {
self.output += ",";

if let Some((ref config, ref pretty)) = self.pretty {
if pretty.indent < config.depth_limit {
if pretty.indent <= config.depth_limit {
self.output += &config.new_line;
}
}
Expand Down Expand Up @@ -734,7 +734,7 @@ impl<'a> ser::SerializeStruct for &'a mut Serializer {
self.output += ",";

if let Some((ref config, ref pretty)) = self.pretty {
if pretty.indent < config.depth_limit {
if pretty.indent <= config.depth_limit {
self.output += &config.new_line;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/depth_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn depth_limit() {
};

let pretty = ron::ser::PrettyConfig::new()
.with_depth_limit(2)
.with_depth_limit(1)
.with_separate_tuple_members(true)
.with_enumerate_arrays(true)
.with_new_line("\n".to_string());
Expand Down

0 comments on commit 068c6f1

Please sign in to comment.