From 626f985e0ac033de68b1fad8e7453f8f624e39d2 Mon Sep 17 00:00:00 2001 From: fw_qaq <82551626+Jack-Zhang-1314@users.noreply.github.com> Date: Mon, 26 Sep 2022 16:18:11 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Update=20=E9=93=BE=E8=A1=A8=E7=90=86?= =?UTF-8?q?=E8=AE=BA=E5=9F=BA=E7=A1=80=20about=20rust?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/链表理论基础.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/problems/链表理论基础.md b/problems/链表理论基础.md index 8378f7f2..455a2bfe 100644 --- a/problems/链表理论基础.md +++ b/problems/链表理论基础.md @@ -218,6 +218,21 @@ class ListNode(_x: Int = 0, _next: ListNode = null) { } ``` +Rust: +```rust +pub struct Node { + value: T, + next: Link, +} + +type Link = Option>>; + +// 附设头节点 +pub struct List { + head: Link, +} +``` + -----------------------
From 5252cfc060bedce7c5fe460a369343265ab92008 Mon Sep 17 00:00:00 2001 From: fw_qaq <82551626+Jack-Zhang-1314@users.noreply.github.com> Date: Wed, 28 Sep 2022 16:40:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?Update=20=E9=93=BE=E8=A1=A8=E7=90=86?= =?UTF-8?q?=E8=AE=BA=E5=9F=BA=E7=A1=80.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/链表理论基础.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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 } + } } ```