Created
November 26, 2022 06:16
-
-
Save DanielAdeniji/9972fcd8775286f23dc45f7db67fb3f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Person | |
{ | |
name: String | |
, age: u8 | |
} | |
fn main() | |
{ | |
// Create struct with field init shorthand | |
//String Literals ( static ) | |
let nameHardCoded:&'static str = "Peter 1"; | |
let age1 = 27; | |
let objPeter1 = Person | |
{ | |
name:nameHardCoded.to_string() | |
, age:age1 | |
}; | |
//Print Person 1 | |
println! | |
( | |
"{0}" | |
, objPeter1 | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment