// Definition for singly-linked list. #[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option> } impl ListNode { #[inline] fn new(val: i32) -> Self { ListNode { next: None, val } } } pub fn make_list(arr: Vec) -> Option> { let mut head: Option> = None; let mut current = &mut head; for &value in arr.iter() { let new_node = Box::new(ListNode::new(value)); if current.is_none() { *current = Some(new_node); } else { current.as_mut().unwrap().next = Some(new_node); current = &mut current.as_mut().unwrap().next; } } head }