aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/guilds.rs9
-rw-r--r--src/main.rs6
2 files changed, 5 insertions, 10 deletions
diff --git a/src/guilds.rs b/src/guilds.rs
index 24ec817..e847841 100644
--- a/src/guilds.rs
+++ b/src/guilds.rs
@@ -39,16 +39,11 @@ pub fn lookup(api_id: &str) -> Option<Guild> {
let mut cache = CACHE.write().unwrap();
let url = format!("https://api.guildwars2.com/v2/guild/{}", api_id);
- let result = ureq::get(&url)
+ let guild: Guild = ureq::get(&url)
.call()
+ .ok()?
.into_json()
.expect("Invalid JSON in API response");
- let name = result["name"].as_str()?;
- let tag = result["tag"].as_str()?;
- let guild = Guild {
- tag: tag.into(),
- name: name.into(),
- };
cache.insert(api_id.into(), guild.clone());
Some(guild)
}
diff --git a/src/main.rs b/src/main.rs
index 9149b17..256de97 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -388,7 +388,7 @@ fn repl(opt: &Opt) -> Result<()> {
loop {
let line = rl.readline("Query> ")?;
rl.add_history_entry(&line);
- maybe_save_history(&rl, history_path.as_ref().map(|r| r as &Path));
+ maybe_save_history(&mut rl, history_path.as_ref().map(|r| r as &Path));
let parsed = build_filter(&line);
INTERRUPTED.store(false, Ordering::Relaxed);
@@ -408,8 +408,8 @@ fn maybe_load_history(rl: &mut Editor<()>, path: Option<&Path>) {
}
}
-fn maybe_save_history(rl: &Editor<()>, path: Option<&Path>) {
- let run = |path: &Path| -> Result<()> {
+fn maybe_save_history(rl: &mut Editor<()>, path: Option<&Path>) {
+ let mut run = |path: &Path| -> Result<()> {
debug!("Saving history to {:?}", path);
let parent = path
.parent()