From 7803388377332c18559fa19296b064aa076a1f1b Mon Sep 17 00:00:00 2001 From: fw_qaq <82551626+Jack-Zhang-1314@users.noreply.github.com> Date: Sat, 5 Nov 2022 14:30:53 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BA=8C=E5=8F=89=E6=A0=91=E7=90=86?= =?UTF-8?q?=E8=AE=BA=E5=9F=BA=E7=A1=80.md=20about=20rust?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/二叉树理论基础.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/problems/二叉树理论基础.md b/problems/二叉树理论基础.md index e377626c..d520273a 100644 --- a/problems/二叉树理论基础.md +++ b/problems/二叉树理论基础.md @@ -270,6 +270,29 @@ class TreeNode(_value: Int = 0, _left: TreeNode = null, _right: TreeNode = null) var right: TreeNode = _right } ``` + +rust: + +```rust +#[derive(Debug, PartialEq, Eq)] +pub struct TreeNode { + pub val: i32, + pub left: Option>>, + pub right: Option>>, +} + +impl TreeNode { + #[inline] + pub fn new(val: i32) -> Self { + TreeNode { + val, + left: None, + right: None, + } + } +} +``` +