Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub struct MyStruct{
- var1 : i32, // private
- }
- impl MyStruct {
- pub fn new() -> MyStruct {
- MyStruct { var1: MyStruct::get_var() }
- }
- fn get_var() -> i32 {
- return 10;
- }
- }
- fn main() {
- let ms = MyStruct::new();
- println!("Var1 = {}", ms.var1);
- }
Add Comment
Please, Sign In to add comment