by Luker88 · 4y ago · 0 comments
It felt like someone was trying to force functional programming on rust, with typenames from java.
Sure it works but the code looked very verbose, and the ridiculous types like 'ApplicationCommandInteractionDataOptionValue' definitely did not help.
Serenity works well, it's just definitely not rust-style.
With forced functional programming, you may be referring to serenity's builders? For example
.send_message(|m| m
.content("text")
.embed(|e| e
.description("...")
.timestamp("...")
)
.components(|c| c
.create_action_row(|r| r
.create_button(|b| b
.style(ButtonStyle::Primary)
.label("press me")
.custom_id("button1")
)
)
)
).await?;
In the next breaking release (`next` branch in git), we have a new by-value builder style which has
turned out to be a better design in many ways: .send_message(CreateMessage::new()
.content("text")
.embed(CreateEmbed::new()
.description("...")
.timestamp("...")
)
.components(CreateComponents::new()
.add_action_row(CreateActionRow::new()
.add_button(
CreateButton::new(ButtonStyle::Primary, "button1").label("press me")
)
)
)
)
And a PR is open to make the API even better (replace redundant CreateComponents with Vec<CreateActionRow>) and more will be coming presumably.Does this seem more rusty to you? We're open to more criticism - developmenet on serenity is quite active currently (e.g. 52 PRs merged in the last month)