Skip to content

Commit

Permalink
impr: replace try! with ?
Browse files Browse the repository at this point in the history
Replace all instances of `try!` with the new `?` operator.
Remove unnecessary TODO comment.
  • Loading branch information
indiv0 committed Feb 17, 2017
1 parent c4c9e8d commit d7059a3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use serde::Deserialize;
fn parse_wolfram_alpha_response<T>(response: &str) -> Result<T>
where T: Debug + Deserialize,
{
let parsed_response = try!(serde_xml::from_str(response));
let parsed_response = serde_xml::from_str(response)?;
trace!("Parsed response: {:?}", parsed_response);
Ok(parsed_response)
}
Expand Down Expand Up @@ -107,9 +107,9 @@ mod hyper_support {
url.query_pairs_mut().extend_pairs(params.into_iter());

trace!("Sending query \"{:?}\" to url: {}", params, url);
let mut response = try!(self.get(url).send());
let mut response = self.get(url).send()?;
let mut result = String::new();
try!(response.read_to_string(&mut result));
response.read_to_string(&mut result)?;
trace!("Query result: {}", result);

Ok(result)
Expand Down
1 change: 0 additions & 1 deletion src/model.in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ impl Deserialize for States {

struct StatesVisitor;

// TODO: remove all try!s
impl Visitor for StatesVisitor {
type Value = States;

Expand Down
2 changes: 1 addition & 1 deletion src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ pub fn query<R>(
}
}

let response = try!(client.send_authed("query", appid, &mut params));
let response = client.send_authed("query", appid, &mut params)?;
parse_wolfram_alpha_response(&response)
}

0 comments on commit d7059a3

Please sign in to comment.