/*
Common format specifiers
-----------------------------------
{:<10} // Left-align, width 10
{:>10} // Right-align, width 10
{:^10} // Center-align, width 10
{:08} // Width 8, pad with zeros
{:.2} // 2 decimal places
{:10.2} // Width 10, 2 decimal places
*/
/// Formats a record using fixed-width fields.
///
/// {:<15} = left-align text in a field 15 characters wide
/// {:>10} = right-align integer in a field 10 characters wide
/// {:>12.2} = right-align floating-point number in a field
/// 12 characters wide with 2 decimal places
fn format_record(name: &str, age: u32, salary: f64) -> String {
format!("{:<15}{:>10}{:>12.2}", name, age, salary)
}
fn main() {
// Store the formatted string in a variable
let result = format_record("Alice", 61, 215000.0);
println!("{}", result);
}
/*
run:
Alice 61 215000.00
*/