Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply formatting fix to published crate #260

Merged
merged 3 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Next

## [0.6.1] - 2020-07-14

### Fixes
- Fix array formatting regression ([#260](https://github.com/ron-rs/ron/pull/260))

## [0.6.0] - 2020-05-21
### Additions
- Implement integer support in Numbers ([#210](https://github.com/ron-rs/ron/pull/210))
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ron"
# Memo: update version in src/lib.rs too (doc link)
version = "0.6.0"
version = "0.6.1"
license = "MIT/Apache-2.0"
keywords = ["parser", "serde", "serialization"]
authors = [
Expand Down
27 changes: 14 additions & 13 deletions src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,22 +607,22 @@ impl<'a, W: io::Write> ser::SerializeSeq for Compound<'a, W> {
ser,
} => {
ser.output.write_all(b",")?;
if let Some((ref config, ref mut pretty)) = ser.pretty {
if pretty.indent <= config.depth_limit {
if config.enumerate_arrays {
assert!(config.new_line.contains('\n'));
let index = pretty.sequence_index.last_mut().unwrap();
//TODO: when /**/ comments are supported, prepend the index
// to an element instead of appending it.
write!(ser.output, "// [{}]", index).unwrap();
*index += 1;
}
ser.output.write_all(config.new_line.as_bytes())?;
}
}
ser
}
};
if let Some((ref config, ref mut pretty)) = ser.pretty {
if pretty.indent <= config.depth_limit {
if config.enumerate_arrays {
assert!(config.new_line.contains('\n'));
let index = pretty.sequence_index.last_mut().unwrap();
//TODO: when /**/ comments are supported, prepend the index
// to an element instead of appending it.
write!(ser.output, "// [{}]", index).unwrap();
*index += 1;
}
ser.output.write_all(config.new_line.as_bytes())?;
}
}
ser.indent()?;

value.serialize(&mut **ser)?;
Expand All @@ -639,6 +639,7 @@ impl<'a, W: io::Write> ser::SerializeSeq for Compound<'a, W> {
if let Some((ref config, ref mut pretty)) = ser.pretty {
if pretty.indent <= config.depth_limit {
ser.output.write_all(b",")?;
ser.output.write_all(config.new_line.as_bytes())?;
}
}
ser
Expand Down
14 changes: 14 additions & 0 deletions tests/240_array_pretty.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use ron::ser::{to_string_pretty, PrettyConfig};

#[test]
fn small_array() {
let arr = &[(), (), ()][..];
assert_eq!(
to_string_pretty(&arr, PrettyConfig::new().with_new_line("\n".to_string())).unwrap(),
"[
(),
(),
(),
]"
);
}