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