aboutsummaryrefslogtreecommitdiff
path: root/src/framework
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-10-03 16:55:58 +0200
committerZeyla Hellyer <[email protected]>2017-10-09 15:47:48 -0700
commit06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a (patch)
treeeee16dc9d1c35e2b17a0a59d55cc85fa82726587 /src/framework
parentUse the de-generification trick. (diff)
downloadserenity-06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a.tar.xz
serenity-06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a.zip
Revert "Use the de-generification trick."
Makes the compiliation time just a bit worse
Diffstat (limited to 'src/framework')
-rw-r--r--src/framework/standard/mod.rs38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/framework/standard/mod.rs b/src/framework/standard/mod.rs
index aa8a5e7..e735100 100644
--- a/src/framework/standard/mod.rs
+++ b/src/framework/standard/mod.rs
@@ -236,9 +236,10 @@ impl StandardFramework {
/// .bucket("basic")
/// .exec_str("pong!")));
/// ```
- pub fn bucket(mut self, s: &str, delay: i64, time_span: i64, limit: i32) -> Self {
+ pub fn bucket<S>(mut self, s: S, delay: i64, time_span: i64, limit: i32) -> Self
+ where S: Into<String> {
self.buckets.insert(
- s.to_string(),
+ s.into(),
Bucket {
ratelimit: Ratelimit {
delay: delay,
@@ -281,8 +282,8 @@ impl StandardFramework {
///
/// [`bucket`]: #method.bucket
#[cfg(feature = "cache")]
- pub fn complex_bucket<Check>(mut self,
- s: &str,
+ pub fn complex_bucket<S, Check>(mut self,
+ s: S,
delay: i64,
time_span: i64,
limit: i32,
@@ -291,9 +292,10 @@ impl StandardFramework {
where Check: Fn(&mut Context, Option<GuildId>, ChannelId, UserId) -> bool
+ Send
+ Sync
- + 'static {
+ + 'static,
+ S: Into<String> {
self.buckets.insert(
- s.to_string(),
+ s.into(),
Bucket {
ratelimit: Ratelimit {
delay,
@@ -334,16 +336,17 @@ impl StandardFramework {
///
/// [`bucket`]: #method.bucket
#[cfg(not(feature = "cache"))]
- pub fn complex_bucket<Check>(mut self,
- s: &str,
+ pub fn complex_bucket<S, Check>(mut self,
+ s: S,
delay: i64,
time_span: i64,
limit: i32,
check: Check)
-> Self
- where Check: Fn(&mut Context, ChannelId, UserId) -> bool + Send + Sync + 'static {
+ where Check: Fn(&mut Context, ChannelId, UserId) -> bool + Send + Sync + 'static,
+ S: Into<String> {
self.buckets.insert(
- s.to_string(),
+ s.into(),
Bucket {
ratelimit: Ratelimit {
delay,
@@ -378,9 +381,10 @@ impl StandardFramework {
/// .bucket("simple")
/// .exec_str("pong!")));
/// ```
- pub fn simple_bucket(mut self, s: &str, delay: i64) -> Self {
+ pub fn simple_bucket<S>(mut self, s: S, delay: i64) -> Self
+ where S: Into<String> {
self.buckets.insert(
- s.to_string(),
+ s.into(),
Bucket {
ratelimit: Ratelimit {
delay: delay,
@@ -623,8 +627,8 @@ impl StandardFramework {
/// let _ = ctx.say("pong");
/// }));
/// ```
- pub fn command<F>(mut self, command_name: &str, f: F) -> Self
- where F: FnOnce(CreateCommand) -> CreateCommand {
+ pub fn command<F, S>(mut self, command_name: S, f: F) -> Self
+ where F: FnOnce(CreateCommand) -> CreateCommand, S: Into<String> {
{
let ungrouped = self.groups
.entry("Ungrouped".to_string())
@@ -632,7 +636,7 @@ impl StandardFramework {
if let Some(ref mut group) = Arc::get_mut(ungrouped) {
let cmd = f(CreateCommand(Command::default())).0;
- let name = command_name.to_string();
+ let name = command_name.into();
if let Some(ref prefix) = group.prefix {
for v in &cmd.aliases {
@@ -682,8 +686,8 @@ impl StandardFramework {
/// .command("ping", |c| c.exec_str("pong!"))
/// .command("pong", |c| c.exec_str("ping!"))));
/// ```
- pub fn group<F>(mut self, group_name: &str, f: F) -> Self
- where F: FnOnce(CreateGroup) -> CreateGroup {
+ pub fn group<F, S>(mut self, group_name: S, f: F) -> Self
+ where F: FnOnce(CreateGroup) -> CreateGroup, S: Into<String> {
let group = f(CreateGroup(CommandGroup::default())).0;
self.groups.insert(group_name.into(), Arc::new(group));