rust_template/module_lib/
hello_world.rs

1/// Prints a personalized greeting message to the console.
2///
3/// # Parameters
4/// - `name`: The name of the person or entity to greet.
5/// - `times`: The number of times the greeting should be printed.
6///
7/// # Example
8/// ```
9/// use rust_template::module_lib::hello_world::greet;
10///
11/// greet("John", 3);
12/// // Output:
13/// // Hello, John!
14/// // Hello, John!
15/// // Hello, John!
16/// ```
17///
18/// # Panics (Explain under what conditions this function will panic)
19/// This function will panic if `times` is set to 0.
20///
21/// # Errors (Describe any errors that may be returned)
22/// None.
23///
24/// # Safety (Document any safety considerations)
25/// This function is safe to use and does not perform any unsafe operations.
26pub fn greet(name: &str, times: usize) {
27    if times == 0 {
28        panic!("The `times` parameter must be greater than 0.");
29    }
30
31    for _ in 0..times {
32        println!("Hello, {}!", name);
33    }
34}
35
36 
37#[doc(hidden)] // Hide the function from the documentation
38pub fn goodbye() {
39    println!("Goodbye!");
40}