3 ms·
Not exactly what you want, but one option is to do something like: struct OptionsStruct {...} impl Default for OptionsStruct {...} impl Add for O
by lalaithion 6y ago
Not exactly what you want, but one option is to do something like:
struct OptionsStruct {...}
impl Default for OptionsStruct {...}
impl Add for OptionsStruct {...}
fn port(portnum : u16) -> OptionsStruct {...}
fn timeout(millis: u64) -> OptionsStruct {...}
fn maxconns(conns: usize) -> OptionsStruct {...}
fn main() {
...
// startServer("localhost", default())
startServer("localhost", port(54321) + timeout(1000));
...
}
Not the most ergonomic, I know, and requires custom architecting for each instance of this, but somewhat doable.