Macro leetcode_trees_rs::list_node
source · macro_rules! list_node { ($val:expr) => { ... }; ($val:expr, $($rest:tt)*) => { ... }; }
Expand description
§Description
A macro to reduce the boilerplate in generating a full ListNode.
§Example
This code:
use crate::utils::list_node;
let node = list_node!(1, 2, 3, 4);
Is the equivalent of the following:
use crate::utils::ListNode;
let node = ListNode {
val: 1,
next: Some(Box(ListNode {
val: 2,
next: Some(Box(ListNode {
val: 3,
next: ListNode::new(4),
}))
}))
}