Skip to content

Commit 7aa23e0

Browse files
authored
small simplification of macros (#758)
1 parent 2c30a7f commit 7aa23e0

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

insta/src/macros.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -248,24 +248,21 @@ macro_rules! _assert_serialized_snapshot {
248248
// and pass to `_assert_snapshot_base`
249249
(format=$format:ident, $value:expr, $(match ..)? {$($k:expr => $v:expr),* $(,)?} $($arg:tt)*) => {{
250250
let transform = |value| {
251-
let (_, value) = $crate::_prepare_snapshot_for_redaction!(value, {$($k => $v),*}, $format);
252-
value
251+
$crate::_prepare_snapshot_for_redaction!(value, {$($k => $v),*}, $format)
253252
};
254253
$crate::_assert_snapshot_base!(transform=transform, $value $($arg)*);
255254
}};
256255
// If there's a name, redaction expressions, and debug_expr, capture and pass all to `_assert_snapshot_base`
257256
(format=$format:ident, $name:expr, $value:expr, $(match ..)? {$($k:expr => $v:expr),* $(,)?}, $debug_expr:expr $(,)?) => {{
258257
let transform = |value| {
259-
let (_, value) = $crate::_prepare_snapshot_for_redaction!(value, {$($k => $v),*}, $format);
260-
value
258+
$crate::_prepare_snapshot_for_redaction!(value, {$($k => $v),*}, $format)
261259
};
262260
$crate::_assert_snapshot_base!(transform=transform, $name, $value, $debug_expr);
263261
}};
264262
// If there's a name and redaction expressions, capture and pass to `_assert_snapshot_base`
265263
(format=$format:ident, $name:expr, $value:expr, $(match ..)? {$($k:expr => $v:expr),* $(,)?} $(,)?) => {{
266264
let transform = |value| {
267-
let (_, value) = $crate::_prepare_snapshot_for_redaction!(value, {$($k => $v),*}, $format);
268-
value
265+
$crate::_prepare_snapshot_for_redaction!(value, {$($k => $v),*}, $format)
269266
};
270267
$crate::_assert_snapshot_base!(transform=transform, $name, $value);
271268
}};
@@ -276,7 +273,7 @@ macro_rules! _assert_serialized_snapshot {
276273
&value,
277274
$crate::_macro_support::SerializationFormat::$format,
278275
)};
279-
$crate::_assert_snapshot_base!(transform = transform, $($arg)*);
276+
$crate::_assert_snapshot_base!(transform=transform, $($arg)*);
280277
}};
281278
}
282279

@@ -292,12 +289,11 @@ macro_rules! _prepare_snapshot_for_redaction {
292289
$crate::_macro_support::Redaction::from($v)
293290
),)*
294291
];
295-
let value = $crate::_macro_support::serialize_value_redacted(
292+
$crate::_macro_support::serialize_value_redacted(
296293
&$value,
297294
&vec,
298295
$crate::_macro_support::SerializationFormat::$format,
299-
);
300-
(vec, value)
296+
)
301297
}
302298
}
303299
}

0 commit comments

Comments
 (0)