Function leetcode_test_utils::tree::shortcuts::val[][src]

pub fn val(p: *const TreeNode) -> i32
Expand description

Access the value pointed by the given pointer.

This function is a shortcut for getting the value pointed by p. It is often used for pointer gotten by calling as_ptr() on whatever coerces to RefCell<TreeNode>.

Safety

  • The pointer must not be null, or the program will crash.

Examples

use leetcode_test_utils::tree::shortcuts::{new_node, val};
let node = new_node(42);
let pointer = node.as_ref().unwrap().as_ptr();
assert_eq!(val(pointer), 42);