diff options
| author | Austin Hellyer <[email protected]> | 2017-01-08 08:45:17 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2017-01-08 08:45:17 -0800 |
| commit | a658105f7499efe994280906e85fd51c2b70c3a7 (patch) | |
| tree | 4c8af6a353b9fece3f5a9d9a9e7a90f25d53cc79 /src/model/utils.rs | |
| parent | Wait 5s between shard boots (diff) | |
| download | serenity-a658105f7499efe994280906e85fd51c2b70c3a7.tar.xz serenity-a658105f7499efe994280906e85fd51c2b70c3a7.zip | |
Code style cleanup
Diffstat (limited to 'src/model/utils.rs')
| -rw-r--r-- | src/model/utils.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/model/utils.rs b/src/model/utils.rs index e499fd2..71b4a52 100644 --- a/src/model/utils.rs +++ b/src/model/utils.rs @@ -29,9 +29,9 @@ use ::ext::cache::ChannelRef; macro_rules! req { ($opt:expr) => { $opt.ok_or(Error::Decode(concat!("Type mismatch in model:", - line!(), - ": ", - stringify!($opt)), + line!(), + ": ", + stringify!($opt)), Value::Null))? } } @@ -100,6 +100,9 @@ pub fn decode_members(value: Value) -> Result<HashMap<UserId, Member>> { } // Clippy's lint is incorrect here and will result in invalid code. +// +// Bit more detaul: `result_unwrap_or_default` is not yet stable as of rustc +// 1.14. #[allow(or_fun_call)] pub fn decode_notes(value: Value) -> Result<HashMap<UserId, String>> { let mut notes = HashMap::new(); @@ -263,7 +266,8 @@ pub fn into_u64(value: Value) -> Result<u64> { } } -pub fn opt<T, F: FnOnce(Value) -> Result<T>>(map: &mut BTreeMap<String, Value>, key: &str, f: F) -> Result<Option<T>> { +pub fn opt<F, T>(map: &mut BTreeMap<String, Value>, key: &str, f: F) + -> Result<Option<T>> where F: FnOnce(Value) -> Result<T> { match map.remove(key) { None | Some(Value::Null) => Ok(None), Some(val) => f(val).map(Some), @@ -289,7 +293,6 @@ pub fn remove(map: &mut BTreeMap<String, Value>, key: &str) -> Result<Value> { }) } -#[doc(hidden)] #[cfg(all(feature="cache", feature="methods"))] pub fn user_has_perms(channel_id: ChannelId, mut permissions: Permissions) |