hello_world_x_rust_x_library/lib.rs
1//! This crate provides functions needed for Hello World applications.
2
3/// This function takes an optional name and returns a greeting
4///
5/// # Examples
6///
7/// If no name is given, it will return the default greeting
8///
9/// ```
10/// use hello_world_x_rust_x_library::greet;
11///
12/// assert_eq!("Hello, world!", greet(None));
13/// ```
14///
15/// If a name is given, it will return a customized greeting
16///
17/// ```
18/// use hello_world_x_rust_x_library::greet;
19///
20/// assert_eq!("Hello, intrepion!", greet(Some("intrepion")));
21/// ```
22pub fn greet(name: Option<&str>) -> String {
23 match name {
24 Some(name) => format!("Hello, {}!", name),
25 None => "Hello, world!".to_string(),
26 }
27}