On Monday, 11 September 2023 at 17:51:04 UTC, BoQsc wrote:
I would like to set function's default struct for a function in a way that it would be visible for the reader to see what options are set. Something like `Options option = {silenceErrors: false}`

If the function's defaults will always match the default initializers of the struct itself,
```d
struct Options {
    bool silenceErrors = false;
}
void someFunction(Options option = Options.init) {
        writeln(option);
}
```
else:
```d
struct Options {
    bool silenceErrors = false;
}
void someFunction(Options option = Options(silenceErrors: true)) {
        writeln(option);
}
```

Reply via email to