Skip to content

Commit 28bc0d5

Browse files
authored
Fix ownership issue (#453)
1 parent 23c045d commit 28bc0d5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ macro_rules! _assert_snapshot_base {
347347
$crate::_macro_support::assert_snapshot(
348348
$name.into(),
349349
#[allow(clippy::redundant_closure_call)]
350-
&$transform($value),
350+
&$transform(&$value),
351351
env!("CARGO_MANIFEST_DIR"),
352352
$crate::_function_name!(),
353353
module_path!(),

src/snapshot.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,3 +917,13 @@ fn test_parse_yaml_error() {
917917
assert!(error.contains("Failed parsing the YAML from"));
918918
assert!(error.contains("/bad.yaml"));
919919
}
920+
921+
/// Check that snapshots don't take ownership of the value
922+
#[test]
923+
fn test_ownership() {
924+
// Range is non-copy
925+
use std::ops::Range;
926+
let r = Range { start: 0, end: 10 };
927+
assert_debug_snapshot!(r, @"0..10");
928+
assert_debug_snapshot!(r, @"0..10");
929+
}

0 commit comments

Comments
 (0)