Update 24. 两两交换链表中的节点 about rust 优化

This commit is contained in:
fw_qaq
2023-03-29 16:44:08 +08:00
committed by GitHub
parent d2bbea431e
commit c835ec07b6

View File

@ -410,7 +410,7 @@ impl Solution {
// 递归
impl Solution {
pub fn swap_pairs(head: Option<Box<ListNode>>) -> Option<Box<ListNode>> {
if head == None || head.as_ref().unwrap().next == None {
if head.is_none() || head.as_ref().unwrap().next.is_none() {
return head;
}