track_move

Function track_move 

Source
pub fn track_move<T>(from_name: &str, to_name: &str, value: T) -> T
Expand description

Track an ownership move.

Records a Move event and returns the value unchanged. Use this when ownership transfers from one variable to another.

§Arguments

  • from_name - Name of the source variable (giving up ownership)
  • to_name - Name of the destination variable (receiving ownership)
  • value - The value being moved (returned unchanged)

§Returns

The input value, unchanged.

§Examples

let s1 = track_new("s1", String::from("hello"));
let s2 = track_move("s1", "s2", s1);
// s1 is no longer valid, s2 owns the String

let events = get_events();
assert!(events[1].is_move());