Skip to content
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
54 changes: 38 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion insta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ csv = { version = "1.1.6", optional = true }
console = { version = "0.15.4", optional = true, default-features = false }
pest = { version = "2.1.3", optional = true }
pest_derive = { version = "2.1.0", optional = true }
ron = { version = "0.7.1", optional = true }
ron = { version = "0.12.0", optional = true }
toml = { version = "0.5.7", optional = true }
globset = { version = ">= 0.4.6, < 0.4.17", optional = true }
walkdir = { version = "2.3.1", optional = true }
Expand Down
12 changes: 7 additions & 5 deletions insta/src/serialization.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use serde::de::value::Error as ValueError;
use serde::Serialize;
#[cfg(feature = "ron")]
use std::borrow::Cow;

use crate::content::{json, yaml, Content, ContentSerializer};
use crate::settings::Settings;
Expand Down Expand Up @@ -61,19 +63,19 @@ pub fn serialize_content(mut content: Content, format: SerializationFormat) -> S
}
#[cfg(feature = "ron")]
SerializationFormat::Ron => {
let mut buf = Vec::new();
let mut buf = String::new();
let mut config = ron::ser::PrettyConfig::new();
config.new_line = "\n".to_string();
config.indentor = " ".to_string();
config.new_line = Cow::Borrowed("\n");
config.indentor = Cow::Borrowed(" ");
config.struct_names = true;
let mut serializer = ron::ser::Serializer::with_options(
&mut buf,
Some(config),
ron::options::Options::default(),
&ron::options::Options::default(),
)
.unwrap();
content.serialize(&mut serializer).unwrap();
String::from_utf8(buf).unwrap()
buf
}
#[cfg(feature = "toml")]
SerializationFormat::Toml => {
Expand Down
Loading