aboutsummaryrefslogtreecommitdiff
path: root/src/client/context.rs
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-08-24 15:26:49 +0200
committeracdenisSK <[email protected]>2017-08-24 16:36:01 +0200
commitb3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3 (patch)
tree315e16f7b252d22b5f832302e722a85c9e6a9b6e /src/client/context.rs
parentAllow FromStr for User to use REST (#147) (diff)
downloadserenity-b3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3.tar.xz
serenity-b3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3.zip
Revamp `RwLock` usage in the lib
Also not quite sure if they goofed rustfmt or something, but its changes it did were a bit bizarre.
Diffstat (limited to 'src/client/context.rs')
-rw-r--r--src/client/context.rs34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/client/context.rs b/src/client/context.rs
index a20a316..e8595cd 100644
--- a/src/client/context.rs
+++ b/src/client/context.rs
@@ -75,26 +75,26 @@ impl Context {
/// let mut client = Client::new("token", Handler); client.start().unwrap();
/// ```
#[cfg(feature = "builder")]
- pub fn edit_profile<F: FnOnce(EditProfile) -> EditProfile>(&self, f: F) -> Result<CurrentUser> {
+pub fn edit_profile<F: FnOnce(EditProfile) -> EditProfile>(&self, f: F) -> Result<CurrentUser>{
let mut map = Map::new();
feature_cache! {{
- let cache = CACHE.read().unwrap();
-
- map.insert("username".to_owned(), Value::String(cache.user.name.clone()));
-
- if let Some(email) = cache.user.email.as_ref() {
- map.insert("email".to_owned(), Value::String(email.clone()));
- }
- } else {
- let user = http::get_current_user()?;
-
- map.insert("username".to_owned(), Value::String(user.name.clone()));
-
- if let Some(email) = user.email.as_ref() {
- map.insert("email".to_owned(), Value::String(email.clone()));
- }
- }}
+ let cache = CACHE.read().unwrap();
+
+ map.insert("username".to_owned(), Value::String(cache.user.name.clone()));
+
+ if let Some(email) = cache.user.email.as_ref() {
+ map.insert("email".to_owned(), Value::String(email.clone()));
+ }
+ } else {
+ let user = http::get_current_user()?;
+
+ map.insert("username".to_owned(), Value::String(user.name.clone()));
+
+ if let Some(email) = user.email.as_ref() {
+ map.insert("email".to_owned(), Value::String(email.clone()));
+ }
+ }}
let edited = f(EditProfile(map)).0;