Merge pull request #1664 from Jack-Zhang-1314/patch-3

Update 链表理论基础 about rust
This commit is contained in:
程序员Carl
2022-09-30 10:23:27 +08:00
committed by GitHub

View File

@ -218,6 +218,22 @@ class ListNode(_x: Int = 0, _next: ListNode = null) {
}
```
Rust:
```rust
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode<T> {
pub val: T,
pub next: Option<Box<ListNode<T>>>,
}
impl<T> ListNode<T> {
#[inline]
fn new(val: T, node: Option<Box<ListNode<T>>>) -> Self {
ListNode { next: node, val }
}
}
```
-----------------------
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>