diff --git a/crates/snapbox/src/cmd.rs b/crates/snapbox/src/cmd.rs index 5dd669da..7dd26ed6 100644 --- a/crates/snapbox/src/cmd.rs +++ b/crates/snapbox/src/cmd.rs @@ -630,7 +630,7 @@ impl OutputAssert { #[track_caller] fn stdout_eq_inner(self, expected: crate::Data) -> Self { - let actual = crate::Data::from(self.output.stdout.as_slice()); + let actual = self.output.stdout.as_slice().into_data(); if let Err(err) = self.config.try_eq(expected, actual, Some(&"stdout")) { err.panic(); } @@ -680,7 +680,7 @@ impl OutputAssert { #[track_caller] fn stderr_eq_inner(self, expected: crate::Data) -> Self { - let actual = crate::Data::from(self.output.stderr.as_slice()); + let actual = self.output.stderr.as_slice().into_data(); if let Err(err) = self.config.try_eq(expected, actual, Some(&"stderr")) { err.panic(); } diff --git a/crates/snapbox/src/data/mod.rs b/crates/snapbox/src/data/mod.rs index 5c0450e1..c41f1e4a 100644 --- a/crates/snapbox/src/data/mod.rs +++ b/crates/snapbox/src/data/mod.rs @@ -91,7 +91,7 @@ impl IntoData for Vec { impl IntoData for &'_ [u8] { fn into_data(self) -> Data { - self.to_owned().into() + self.to_owned().into_data() } } @@ -103,13 +103,13 @@ impl IntoData for String { impl IntoData for &'_ String { fn into_data(self) -> Data { - self.to_owned().into() + self.to_owned().into_data() } } impl IntoData for &'_ str { fn into_data(self) -> Data { - self.to_owned().into() + self.to_owned().into_data() } } @@ -671,49 +671,6 @@ impl Default for Data { } } -impl<'d> From<&'d Data> for Data { - fn from(other: &'d Data) -> Self { - other.clone() - } -} - -impl From> for Data { - fn from(other: Vec) -> Self { - Self::binary(other) - } -} - -impl<'b> From<&'b [u8]> for Data { - fn from(other: &'b [u8]) -> Self { - other.to_owned().into() - } -} - -impl From for Data { - fn from(other: String) -> Self { - Self::text(other) - } -} - -impl<'s> From<&'s String> for Data { - fn from(other: &'s String) -> Self { - other.clone().into() - } -} - -impl<'s> From<&'s str> for Data { - fn from(other: &'s str) -> Self { - other.to_owned().into() - } -} - -impl From for super::Data { - fn from(inline: Inline) -> Self { - let trimmed = inline.trimmed(); - super::Data::text(trimmed).with_source(inline) - } -} - #[cfg(feature = "detect-encoding")] fn is_binary(data: &[u8]) -> bool { match content_inspector::inspect(data) { diff --git a/src/runner.rs b/src/runner.rs index 1adcb237..5449bbbb 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -15,6 +15,7 @@ use rayon::prelude::*; use snapbox::data::DataFormat; use snapbox::filters::{Filter as _, FilterNewlines, FilterPaths, FilterRedactions}; use snapbox::path::FileType; +use snapbox::IntoData; #[derive(Debug)] pub(crate) struct Runner { @@ -580,12 +581,12 @@ impl Output { self.spawn.status = SpawnStatus::Ok; self.stdout = Some(Stream { stream: Stdio::Stdout, - content: output.stdout.into(), + content: output.stdout.into_data(), status: StreamStatus::Ok, }); self.stderr = Some(Stream { stream: Stdio::Stderr, - content: output.stderr.into(), + content: output.stderr.into_data(), status: StreamStatus::Ok, }); self