aboutsummaryrefslogtreecommitdiff
path: root/src/cache
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-09-14 08:20:09 -0700
committerZeyla Hellyer <[email protected]>2017-09-14 08:20:09 -0700
commitd0ec12eef5363459d694904ce920365122c68acd (patch)
treec1a1784d3c6bbc9bfa04082b6c75e29403387eef /src/cache
parentPut the cloning at a later stage (diff)
downloadserenity-d0ec12eef5363459d694904ce920365122c68acd.tar.xz
serenity-d0ec12eef5363459d694904ce920365122c68acd.zip
Don't clone in Cache::all_guilds/private_channels
We don't need to clone the Vec, if the user needs to they can.
Diffstat (limited to 'src/cache')
-rw-r--r--src/cache/mod.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/cache/mod.rs b/src/cache/mod.rs
index 27a44e9..9029548 100644
--- a/src/cache/mod.rs
+++ b/src/cache/mod.rs
@@ -234,11 +234,10 @@ impl Cache {
///
/// [`Group`]: ../model/struct.Group.html
/// [`PrivateChannel`]: ../model/struct.PrivateChannel.html
- pub fn all_private_channels(&self) -> Vec<ChannelId> {
+ pub fn all_private_channels(&self) -> Vec<&ChannelId> {
self.groups
.keys()
.chain(self.private_channels.keys())
- .cloned()
.collect()
}
@@ -270,11 +269,10 @@ impl Cache {
/// [`Context`]: ../client/struct.Context.html
/// [`Guild`]: ../model/struct.Guild.html
/// [`Shard`]: ../gateway/struct.Shard.html
- pub fn all_guilds(&self) -> Vec<GuildId> {
+ pub fn all_guilds(&self) -> Vec<&GuildId> {
self.guilds
.keys()
.chain(self.unavailable_guilds.iter())
- .cloned()
.collect()
}
@@ -604,7 +602,7 @@ impl Cache {
pub(crate) fn update<E: CacheUpdate>(&mut self, e: &mut E) -> Option<E::Output> {
e.update(self)
- }
+ }
pub(crate) fn update_user_entry(&mut self, user: &User) {
match self.users.entry(user.id) {