News for hackers. Stuff that matters.
Re:My least favorite Rust type by lalaithion on Monday September 21, 2020 @11:46PM (#24550638)
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.

There are no comments on this comment yet.