Skip to content

Commit

Permalink
Fix ownership issue (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty committed Mar 4, 2024
1 parent 23c045d commit 28bc0d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/macros.rs
Expand Up @@ -347,7 +347,7 @@ macro_rules! _assert_snapshot_base {
$crate::_macro_support::assert_snapshot(
$name.into(),
#[allow(clippy::redundant_closure_call)]
&$transform($value),
&$transform(&$value),
env!("CARGO_MANIFEST_DIR"),
$crate::_function_name!(),
module_path!(),
Expand Down
10 changes: 10 additions & 0 deletions src/snapshot.rs
Expand Up @@ -917,3 +917,13 @@ fn test_parse_yaml_error() {
assert!(error.contains("Failed parsing the YAML from"));
assert!(error.contains("/bad.yaml"));
}

/// Check that snapshots don't take ownership of the value
#[test]
fn test_ownership() {
// Range is non-copy
use std::ops::Range;
let r = Range { start: 0, end: 10 };
assert_debug_snapshot!(r, @"0..10");
assert_debug_snapshot!(r, @"0..10");
}

0 comments on commit 28bc0d5

Please sign in to comment.