diff --git a/problems/链表理论基础.md b/problems/链表理论基础.md index 455a2bfe..cdd861fd 100644 --- a/problems/链表理论基础.md +++ b/problems/链表理论基础.md @@ -220,16 +220,17 @@ class ListNode(_x: Int = 0, _next: ListNode = null) { Rust: ```rust -pub struct Node { - value: T, - next: Link, +#[derive(PartialEq, Eq, Clone, Debug)] +pub struct ListNode { + pub val: T, + pub next: Option>>, } -type Link = Option>>; - -// 附设头节点 -pub struct List { - head: Link, +impl ListNode { + #[inline] + fn new(val: T, node: Option>>) -> Self { + ListNode { next: node, val } + } } ```