Functions are the first line of organization in any program.
fnmain() {greet(); //do one thingask_location(); //do another thing}fngreet() {println!("Hello!");}fnask_location() {println!("Where are you from?");}
We can add unit tests in the same file.
fnmain() {greet();}fngreet() ->String {"Hello, world!".to_string()}#[test] // test attribute indicates, this is a test functionfntest_greet() {assert_eq!("Hello, world!", greet())}
💭 An attribute is a general, free-form metadatum that is interpreted according to name, convention, and language and compiler version.