Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Optional fields in {} constructors
In the last days, I tried to update my Bevy chess GUI from Bevy 0.14 to 0.16, and so I had to study a few of the recent Bevy examples codes. One is Text which has the code segment below. I wonder if there is really no more compact method available for the optional font field?
if cfg!(feature = "default_font") {
(
TextFont {
font_size: 33.0,
// If no font is specified, the default font (a minimal subset of FiraMono) will be used.
..default()
},
TextColor(GOLD.into()),
)
} else {
(
// "default_font" feature is unavailable, load a font to use instead.
TextFont {
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
font_size: 33.0,
..Default::default()
},
TextColor(GOLD.into()),
)
},
5 posts - 3 participants
🏷️ Rust_feed