# Functions

Functions are the first line of organization in any program.

```rust
fn main() {
  greet(); //do one thing
  ask_location(); //do another thing
}

fn greet() {
  println!("Hello!");
}

fn ask_location() {
  println!("Where are you from?");
}
```

We can add unit tests in the same file.

```rust
fn main() {
    greet();
}

fn greet() -> String {
    "Hello, world!".to_string()
}

#[test] // test attribute indicates, this is a test function
fn test_greet() {
    assert_eq!("Hello, world!", greet())
}
```

> 💭 An [attribute](https://doc.rust-lang.org/reference/attributes.html) is a general, free-form **metadatum** that is interpreted according to name, convention, and language and compiler version.
