aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorthelearnerofcode <[email protected]>2017-11-07 14:51:57 -0800
committerthelearnerofcode <[email protected]>2017-11-07 14:51:57 -0800
commite5a6f3a8ed367bd3d780fd23a0a27f8a80567879 (patch)
tree9b51a6cd25ec63f8a0b2143827e675b04f9bb1af /src
parentInto<String> -> Display (diff)
downloadserenity-e5a6f3a8ed367bd3d780fd23a0a27f8a80567879.tar.xz
serenity-e5a6f3a8ed367bd3d780fd23a0a27f8a80567879.zip
Add Debug derives to more public types
Diffstat (limited to 'src')
-rw-r--r--src/framework/standard/command.rs21
-rw-r--r--src/framework/standard/create_command.rs1
-rw-r--r--src/internal/timer.rs1
-rw-r--r--src/model/utils.rs2
-rw-r--r--src/utils/message_builder.rs10
5 files changed, 30 insertions, 5 deletions
diff --git a/src/framework/standard/command.rs b/src/framework/standard/command.rs
index be7ec2a..8afb583 100644
--- a/src/framework/standard/command.rs
+++ b/src/framework/standard/command.rs
@@ -17,6 +17,7 @@ pub type AfterHook = Fn(&mut Context, &Message, &str, Result<(), Error>) + Send
pub(crate) type InternalCommand = Arc<Command>;
pub type PrefixCheck = Fn(&mut Context, &Message) -> Option<String> + Send + Sync + 'static;
+#[derive(Debug)]
pub enum CommandOrAlias {
Alias(String),
Command(InternalCommand),
@@ -41,6 +42,7 @@ pub enum CommandType {
WithCommands(Help),
}
+#[derive(Debug)]
pub struct CommandGroup {
pub prefix: Option<String>,
pub commands: HashMap<String, CommandOrAlias>,
@@ -98,6 +100,25 @@ impl Command {
}
}
+impl fmt::Debug for Command {
+ // TODO: add Command::checks somehow?
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fmt.debug_struct("Command")
+ .field("bucket", &self.bucket)
+ .field("desc", &self.desc)
+ .field("example", &self.example)
+ .field("usage", &self.usage)
+ .field("min_args", &self.min_args)
+ .field("required_permissions", &self.required_permissions)
+ .field("allowed_roles", &self.allowed_roles)
+ .field("help_available", &self.help_available)
+ .field("dm_only", &self.dm_only)
+ .field("guild_only", &self.guild_only)
+ .field("owners_only", &self.owners_only)
+ .finish()
+ }
+}
+
impl Default for Command {
fn default() -> Command {
Command {
diff --git a/src/framework/standard/create_command.rs b/src/framework/standard/create_command.rs
index c1558ce..4788a05 100644
--- a/src/framework/standard/create_command.rs
+++ b/src/framework/standard/create_command.rs
@@ -5,6 +5,7 @@ use std::sync::Arc;
use client::Context;
use model::{Message, Permissions};
+#[derive(Debug)]
pub struct CreateCommand(pub Command);
impl CreateCommand {
diff --git a/src/internal/timer.rs b/src/internal/timer.rs
index 6a8bf74..68d817a 100644
--- a/src/internal/timer.rs
+++ b/src/internal/timer.rs
@@ -2,6 +2,7 @@ use chrono::{DateTime, Duration, Utc};
use std::thread;
use std::time::Duration as StdDuration;
+#[derive(Debug)]
pub struct Timer {
due: DateTime<Utc>,
duration: Duration,
diff --git a/src/model/utils.rs b/src/model/utils.rs
index fd103c0..26ec7fe 100644
--- a/src/model/utils.rs
+++ b/src/model/utils.rs
@@ -187,6 +187,7 @@ pub fn user_has_perms(channel_id: ChannelId, mut permissions: Permissions) -> Re
Ok(permissions.is_empty())
}
+#[derive(Debug)]
pub struct U16Visitor;
impl<'de> Visitor<'de> for U16Visitor {
@@ -216,6 +217,7 @@ impl<'de> Visitor<'de> for U16Visitor {
fn visit_u64<E: DeError>(self, v: u64) -> StdResult<Self::Value, E> { Ok(v as u16) }
}
+#[derive(Debug)]
pub struct U64Visitor;
impl<'de> Visitor<'de> for U64Visitor {
diff --git a/src/utils/message_builder.rs b/src/utils/message_builder.rs
index 284ba1e..c00cd0a 100644
--- a/src/utils/message_builder.rs
+++ b/src/utils/message_builder.rs
@@ -767,7 +767,7 @@ pub enum ContentModifier {
}
/// Describes formatting on string content
-#[derive(Default, Clone)]
+#[derive(Debug, Default, Clone)]
pub struct Content {
pub italic: bool,
pub bold: bool,
@@ -912,15 +912,15 @@ impl From<ContentModifier> for Content {
mod private {
use super::{Content, ContentModifier};
use std::fmt;
-
+
pub trait A {}
-
+
impl A for ContentModifier {}
impl A for Content {}
impl<T: fmt::Display> A for T {}
}
-
+
/// This trait only exists as way to bypass the shouting of the compiler. Specifically "conflicting
/// implementations in core" and alike.
/// However is not meant to be used outside.
@@ -940,7 +940,7 @@ impl<T: fmt::Display> I for T {
}
}
}
-
+
impl I for ContentModifier {
fn into(self) -> Content { self.to_content() }
}