aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-10-18 12:06:09 -0700
committerZeyla Hellyer <[email protected]>2017-10-18 12:06:09 -0700
commit65e3279ce7b3c4807e8b1310551e9493d3868b94 (patch)
tree1a0cea555659bd7f77e37a1b00d51c3ad102d546 /src/model
parentSlightly improve performance of builders (diff)
downloadserenity-65e3279ce7b3c4807e8b1310551e9493d3868b94.tar.xz
serenity-65e3279ce7b3c4807e8b1310551e9493d3868b94.zip
Change CreateEmbed::field{,s} to not take builders
Change the `field` and `fields` methods on `builder::CreateEmbed` to not accept a `CreateEmbedField` builder. The embed field builder realistically only had (and most likely, only will) have one optional argument, so the parameters may as well be on `CreateEmbed::field`.
Diffstat (limited to 'src/model')
-rw-r--r--src/model/channel/embed.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/model/channel/embed.rs b/src/model/channel/embed.rs
index 74c503d..401f10d 100644
--- a/src/model/channel/embed.rs
+++ b/src/model/channel/embed.rs
@@ -83,10 +83,7 @@ impl Embed {
/// let embed = Embed::fake(|e| e
/// .title("Embed title")
/// .description("Making a basic embed")
- /// .field(|f| f
- /// .name("A field")
- /// .value("Has some content.")
- /// .inline(false)));
+ /// .field("A field", "Has some content.", false));
/// ```
#[inline]
pub fn fake<F>(f: F) -> Value
@@ -127,6 +124,24 @@ pub struct EmbedField {
pub value: String,
}
+impl EmbedField {
+ /// Creates a new embed field.
+ ///
+ /// **Note**: Refer to the [`name`] and [`value`] documentation for maximum
+ /// lengths.
+ ///
+ /// [`name`]: #structfield.name
+ /// [`value`]: #structfield.value
+ pub fn new<T, U>(name: T, value: U, inline: bool) -> Self
+ where T: Into<String>, U: Into<String> {
+ Self {
+ name: name.into(),
+ value: value.into(),
+ inline,
+ }
+ }
+}
+
/// Footer information for an embed.
#[derive(Clone, Debug, Deserialize)]
pub struct EmbedFooter {