From 78be51f432b63fa1c28d2958d232b06c6af428a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E8=A7=85?= Date: Fri, 9 Oct 2026 22:32:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust_project/src/main.rs | 7 ++++++- rust_project/src/second.rs | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 rust_project/src/second.rs diff --git a/rust_project/src/main.rs b/rust_project/src/main.rs index e7a11a9..c0b36b5 100644 --- a/rust_project/src/main.rs +++ b/rust_project/src/main.rs @@ -1,3 +1,8 @@ +mod second; +use second::ClassName; + fn main() { + let object = ClassName::new(1024); + object.public_method(); println!("Hello, world!"); -} +} \ No newline at end of file diff --git a/rust_project/src/second.rs b/rust_project/src/second.rs new file mode 100644 index 0000000..346a01f --- /dev/null +++ b/rust_project/src/second.rs @@ -0,0 +1,20 @@ +pub struct ClassName { + field: i32, +} + +impl ClassName { + pub fn new(value: i32) -> ClassName { + ClassName { + field: value + } + } + + pub fn public_method(&self) { + println!("from public method"); + self.private_method(); + } + + fn private_method(&self) { + println!("from private method"); + } +} \ No newline at end of file