Macro mini_gl_fb::config [−][src]
The config!
macro is intended to make it easy for us to add new fields in the future while
staying backwards-compatible. This is done by making Config
#[non_exhaustive]
but still
providing Default
, so that users can obtain the defaults and modify it to their liking. The
config!
macro automates this, and makes custom configs just as easy as constructing Config
directly would be.
You can use the macro like this:
let config = config! { resizable: true, invert_y: false }; assert_eq!(config.resizable, true); assert_eq!(config.invert_y, false);
As you can see, it's almost identical to a struct construction. You just use this macro in place
of Config
. As such, it has a minimal impact on user code. That invocation roughly expands to:
let config = { let mut config = Config::default(); config.resizable = true; config.invert_y = false; config };
This way, adding new fields will not affect existing code.
You can also create a copy of an existing config, with only a couple options changed:
let original = config! {}; let copy = config! { invert_y: false, ..original }; assert_eq!(original.invert_y, true); assert_eq!(copy.invert_y, false);