An optional parameter with an initial value of T.init
The config parser automatically recognize non-default initializer,
so that the following:
public struct Config
{
public string greeting = "Welcome home";
}
Will not error out if greeting is not defined in the config file.
However, this relies on the initializer of the field (greeting) being
different from the type initializer (string.init is null).
In some cases, the default value is also the desired initializer, e.g.:
public struct Config
{
/// Maximum number of connections. 0 means unlimited.
public uint connections_limit = 0;
}
In this case, one can add @Optional to the field to inform the parser.
An optional parameter with an initial value of T.init
The config parser automatically recognize non-default initializer, so that the following:
Will not error out if greeting is not defined in the config file. However, this relies on the initializer of the field (greeting) being different from the type initializer (string.init is null). In some cases, the default value is also the desired initializer, e.g.:
In this case, one can add @Optional to the field to inform the parser.