aboutsummaryrefslogtreecommitdiff
path: root/src/model/gateway.rs
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2016-12-07 19:10:21 +0100
committerzeyla <[email protected]>2016-12-07 10:10:21 -0800
commitf69512beaa157775accd4392295dba112adcf1df (patch)
tree0944aeabdec8609393f78b9ec257dc5d09d4f6c0 /src/model/gateway.rs
parentAllow mentionable structs to be used as command arguments (diff)
downloadserenity-f69512beaa157775accd4392295dba112adcf1df.tar.xz
serenity-f69512beaa157775accd4392295dba112adcf1df.zip
Change all try's into ?s
This breaks compatibility with < 1.13, but we didn't support that anyway.
Diffstat (limited to 'src/model/gateway.rs')
-rw-r--r--src/model/gateway.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/model/gateway.rs b/src/model/gateway.rs
index 0b64e24..67a9a42 100644
--- a/src/model/gateway.rs
+++ b/src/model/gateway.rs
@@ -29,11 +29,11 @@ impl Game {
#[doc(hidden)]
pub fn decode(value: Value) -> Result<Option<Game>> {
- let mut map = try!(into_map(value));
+ let mut map = into_map(value)?;
let name = match map.remove("name") {
Some(Value::Null) | None => return Ok(None),
- Some(v) => try!(into_string(v)),
+ Some(v) => into_string(v)?,
};
if name.trim().is_empty() {
@@ -42,8 +42,8 @@ impl Game {
Ok(Some(Game {
name: name,
- kind: try!(opt(&mut map, "type", GameType::decode)).unwrap_or(GameType::Playing),
- url: try!(opt(&mut map, "url", into_string)),
+ kind: opt(&mut map, "type", GameType::decode)?.unwrap_or(GameType::Playing),
+ url: opt(&mut map, "url", into_string)?,
}))
}
}
@@ -51,28 +51,28 @@ impl Game {
impl Presence {
#[doc(hidden)]
pub fn decode(value: Value) -> Result<Presence> {
- let mut value = try!(into_map(value));
- let mut user_map = try!(remove(&mut value, "user").and_then(into_map));
+ let mut value = into_map(value)?;
+ let mut user_map = remove(&mut value, "user").and_then(into_map)?;
let (user_id, user) = if user_map.len() > 1 {
- let user = try!(User::decode(Value::Object(user_map)));
+ let user = User::decode(Value::Object(user_map))?;
(user.id, Some(user))
} else {
- (try!(remove(&mut user_map, "id").and_then(UserId::decode)), None)
+ (remove(&mut user_map, "id").and_then(UserId::decode)?, None)
};
let game = match value.remove("game") {
None | Some(Value::Null) => None,
- Some(v) => try!(Game::decode(v)),
+ Some(v) => Game::decode(v)?,
};
Ok(Presence {
user_id: user_id,
- status: try!(remove(&mut value, "status").and_then(OnlineStatus::decode_str)),
- last_modified: try!(opt(&mut value, "last_modified", |v| Ok(req!(v.as_u64())))),
+ status: remove(&mut value, "status").and_then(OnlineStatus::decode_str)?,
+ last_modified: opt(&mut value, "last_modified", |v| Ok(req!(v.as_u64())))?,
game: game,
user: user,
- nick: try!(opt(&mut value, "nick", into_string)),
+ nick: opt(&mut value, "nick", into_string)?,
})
}
}