Avatar ·

Is there a fast way to initialize struct fields with default values in Rust?

Hello! I started learning Rust and encountered a problem when initializing structs. I have a struct with 10 fields, and I need to set default values for them. Currently I'm doing it like this: ```rust struct Config { host: String, port: u16, timeout: u64, max_connections: u32, use_tls: bool, log_level: String, cache_size: usize, retry_count: u32, enable_metrics: bool, backup_url: String, } fn main() { let config = Config { host: String::from("localhost"), port: 8080, timeout: 30, max_connections: 100, use_tls: false, log_level: String::from("info"), cache_size: 1024, retry_count: 3, enable_metrics: true, backup_url: String::new(), }; } ```