2
pub fn partition(mut head: Option<Box<ListNode>>, x: i32) -> Option<Box<ListNode>> {3
let mut dummy1: Option<Box<ListNode>> = None;4
let mut dummy2: Option<Box<ListNode>> = None;5
let mut r1 = &mut dummy1;6
let mut r2 = &mut dummy2;8
if head.as_ref().unwrap().val < x {10
r1 = &mut r1.as_mut().unwrap().next;12
std::mem::swap(r1, &mut head);13
std::mem::swap(&mut r1.as_mut().unwrap().next, &mut head);15
std::mem::swap(r2, &mut head);16
std::mem::swap(&mut r2.as_mut().unwrap().next, &mut head);17
r2 = &mut r2.as_mut().unwrap().next;21
r1.as_mut().unwrap().next = dummy2;