Skip to content

Commit

Permalink
Use standard feature / dep syntax (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty authored Aug 15, 2024
1 parent 9132d04 commit 2771ed2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
14 changes: 6 additions & 8 deletions insta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,22 @@ glob = ["walkdir", "globset"]
colors = ["console"]

# Serialization formats
# TODO: This could be cleaner by using "dep:csv" without renaming the dep, but
# this technique allows for a lower MSRV
csv = ["dep_csv", "serde"]
csv = ["dep:csv", "serde"]
json = ["serde"]
ron = ["dep_ron", "serde"]
toml = ["dep_toml", "serde"]
ron = ["dep:ron", "serde"]
toml = ["dep:toml", "serde"]
yaml = ["serde"]

# internal feature exclusive to cargo-insta
_cargo_insta_internal = ["clap"]

[dependencies]
dep_csv = { package = "csv", version = "1.1.6", optional = true }
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 }
dep_ron = { package = "ron", version = "0.7.1", optional = true }
dep_toml = { package = "toml", version = "0.5.7", optional = true }
ron = { version = "0.7.1", optional = true }
toml = { version = "0.5.7", optional = true }
globset = { version = "0.4.6", optional = true }
walkdir = { version = "2.3.1", optional = true }
similar = { version = "2.1.0", features = ["inline"] }
Expand Down
10 changes: 5 additions & 5 deletions insta/src/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn serialize_content(
SerializationFormat::Csv => {
let mut buf = Vec::with_capacity(128);
{
let mut writer = dep_csv::Writer::from_writer(&mut buf);
let mut writer = csv::Writer::from_writer(&mut buf);
// if the top-level content we're serializing is a vector we
// want to serialize it multiple times once for each item.
if let Some(content_slice) = content.as_slice() {
Expand All @@ -74,22 +74,22 @@ pub fn serialize_content(
#[cfg(feature = "ron")]
SerializationFormat::Ron => {
let mut buf = Vec::new();
let mut config = dep_ron::ser::PrettyConfig::new();
let mut config = ron::ser::PrettyConfig::new();
config.new_line = "\n".to_string();
config.indentor = " ".to_string();
config.struct_names = true;
let mut serializer = dep_ron::ser::Serializer::with_options(
let mut serializer = ron::ser::Serializer::with_options(
&mut buf,
Some(config),
dep_ron::options::Options::default(),
ron::options::Options::default(),
)
.unwrap();
content.serialize(&mut serializer).unwrap();
String::from_utf8(buf).unwrap()
}
#[cfg(feature = "toml")]
SerializationFormat::Toml => {
let mut rv = dep_toml::to_string_pretty(&content).unwrap();
let mut rv = toml::to_string_pretty(&content).unwrap();
if rv.ends_with('\n') {
rv.truncate(rv.len() - 1);
}
Expand Down

0 comments on commit 2771ed2

Please sign in to comment.