aboutsummaryrefslogtreecommitdiff
path: root/src/framework
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-10-02 22:29:10 +0200
committeracdenisSK <[email protected]>2017-10-02 22:29:10 +0200
commit6a4e52b3fac7d2e96e3a1a67901fbdd4721fb249 (patch)
treeae9ad7d7cb73d4ece6a199796af5975545071493 /src/framework
parent`to_owned` -> `to_string` (diff)
downloadserenity-6a4e52b3fac7d2e96e3a1a67901fbdd4721fb249.tar.xz
serenity-6a4e52b3fac7d2e96e3a1a67901fbdd4721fb249.zip
Use the de-generification trick.
Fixes #168
Diffstat (limited to 'src/framework')
-rw-r--r--src/framework/standard/mod.rs47
1 files changed, 20 insertions, 27 deletions
diff --git a/src/framework/standard/mod.rs b/src/framework/standard/mod.rs
index 92572dd..682a466 100644
--- a/src/framework/standard/mod.rs
+++ b/src/framework/standard/mod.rs
@@ -236,10 +236,9 @@ impl StandardFramework {
/// .bucket("basic")
/// .exec_str("pong!")));
/// ```
- pub fn bucket<S>(mut self, s: S, delay: i64, time_span: i64, limit: i32) -> Self
- where S: Into<String> {
+ pub fn bucket(mut self, s: &str, delay: i64, time_span: i64, limit: i32) -> Self {
self.buckets.insert(
- s.into(),
+ s.to_string(),
Bucket {
ratelimit: Ratelimit {
delay: delay,
@@ -282,8 +281,8 @@ impl StandardFramework {
///
/// [`bucket`]: #method.bucket
#[cfg(feature = "cache")]
- pub fn complex_bucket<S, Check>(mut self,
- s: S,
+ pub fn complex_bucket<Check>(mut self,
+ s: &str,
delay: i64,
time_span: i64,
limit: i32,
@@ -292,10 +291,9 @@ impl StandardFramework {
where Check: Fn(&mut Context, Option<GuildId>, ChannelId, UserId) -> bool
+ Send
+ Sync
- + 'static,
- S: Into<String> {
+ + 'static {
self.buckets.insert(
- s.into(),
+ s.to_string(),
Bucket {
ratelimit: Ratelimit {
delay,
@@ -336,17 +334,16 @@ impl StandardFramework {
///
/// [`bucket`]: #method.bucket
#[cfg(not(feature = "cache"))]
- pub fn complex_bucket<S, Check>(mut self,
- s: S,
+ pub fn complex_bucket<Check>(mut self,
+ s: &str,
delay: i64,
time_span: i64,
limit: i32,
check: Check)
-> Self
- where Check: Fn(&mut Context, ChannelId, UserId) -> bool + Send + Sync + 'static,
- S: Into<String> {
+ where Check: Fn(&mut Context, ChannelId, UserId) -> bool + Send + Sync + 'static {
self.buckets.insert(
- s.into(),
+ s.to_string(),
Bucket {
ratelimit: Ratelimit {
delay,
@@ -381,10 +378,9 @@ impl StandardFramework {
/// .bucket("simple")
/// .exec_str("pong!")));
/// ```
- pub fn simple_bucket<S>(mut self, s: S, delay: i64) -> Self
- where S: Into<String> {
+ pub fn simple_bucket(mut self, s: &str, delay: i64) -> Self {
self.buckets.insert(
- s.into(),
+ s.to_string(),
Bucket {
ratelimit: Ratelimit {
delay: delay,
@@ -596,20 +592,17 @@ impl StandardFramework {
/// });
/// # }
/// ```
- pub fn on<F, S>(mut self, command_name: S, f: F) -> Self
- where F: Fn(&mut Context, &Message, Args) -> Result<(), CommandError> + Send + Sync + 'static,
- S: Into<String> {
+ pub fn on<F>(mut self, command_name: &str, f: F) -> Self
+ where F: Fn(&mut Context, &Message, Args) -> Result<(), CommandError> + Send + Sync + 'static {
{
let ungrouped = self.groups
.entry("Ungrouped".to_string())
.or_insert_with(|| Arc::new(CommandGroup::default()));
if let Some(ref mut group) = Arc::get_mut(ungrouped) {
- let name = command_name.into();
-
group
.commands
- .insert(name, CommandOrAlias::Command(Arc::new(Command::new(f))));
+ .insert(command_name.to_string(), CommandOrAlias::Command(Arc::new(Command::new(f))));
}
}
@@ -629,8 +622,8 @@ impl StandardFramework {
/// let _ = ctx.say("pong");
/// }));
/// ```
- pub fn command<F, S>(mut self, command_name: S, f: F) -> Self
- where F: FnOnce(CreateCommand) -> CreateCommand, S: Into<String> {
+ pub fn command<F>(mut self, command_name: &str, f: F) -> Self
+ where F: FnOnce(CreateCommand) -> CreateCommand {
{
let ungrouped = self.groups
.entry("Ungrouped".to_string())
@@ -638,7 +631,7 @@ impl StandardFramework {
if let Some(ref mut group) = Arc::get_mut(ungrouped) {
let cmd = f(CreateCommand(Command::default())).0;
- let name = command_name.into();
+ let name = command_name.to_string();
if let Some(ref prefix) = group.prefix {
for v in &cmd.aliases {
@@ -688,8 +681,8 @@ impl StandardFramework {
/// .command("ping", |c| c.exec_str("pong!"))
/// .command("pong", |c| c.exec_str("ping!"))));
/// ```
- pub fn group<F, S>(mut self, group_name: S, f: F) -> Self
- where F: FnOnce(CreateGroup) -> CreateGroup, S: Into<String> {
+ pub fn group<F>(mut self, group_name: &str, f: F) -> Self
+ where F: FnOnce(CreateGroup) -> CreateGroup {
let group = f(CreateGroup(CommandGroup::default())).0;
self.groups.insert(group_name.into(), Arc::new(group));