reduce clones and fix some code styles and redundant code

pull/96/head
rhysd 5 years ago
parent 5ba8931502
commit 63e19998d0

@ -155,7 +155,7 @@ pub fn walk_and_embed_assets(
// If a network error occured, warn // If a network error occured, warn
Err(e) => { Err(e) => {
eprintln!("Warning: {}", e,); eprintln!("Warning: {}", e);
// If failed to resolve, replace with absolute URL // If failed to resolve, replace with absolute URL
href_full_url href_full_url
@ -515,9 +515,7 @@ fn get_child_node_by_name(handle: &Handle, node_name: &str) -> Handle {
}); });
match matching_children { match matching_children {
Some(node) => node.clone(), Some(node) => node.clone(),
_ => { _ => handle.clone(),
return handle.clone();
}
} }
} }

@ -28,14 +28,15 @@ pub fn retrieve_asset(
let mut response = client.get(url).send()?; let mut response = client.get(url).send()?;
if !opt_silent { if !opt_silent {
if url == response.url().as_str() { let res_url = response.url().as_str();
if url == res_url {
eprintln!("{}", &url); eprintln!("{}", &url);
} else { } else {
eprintln!("{} -> {}", &url, &response.url().as_str()); eprintln!("{} -> {}", &url, res_url);
} }
} }
let new_cache_key = clean_url(response.url().to_string()); let new_cache_key = clean_url(response.url());
if as_dataurl { if as_dataurl {
// Convert response into a byte array // Convert response into a byte array
@ -54,7 +55,7 @@ pub fn retrieve_asset(
}; };
let dataurl = data_to_dataurl(&mimetype, &data); let dataurl = data_to_dataurl(&mimetype, &data);
// insert in cache // insert in cache
cache.insert(new_cache_key, dataurl.to_string()); cache.insert(new_cache_key, dataurl.clone());
Ok((dataurl, response.url().to_string())) Ok((dataurl, response.url().to_string()))
} else { } else {
let content = response.text().unwrap(); let content = response.text().unwrap();

Loading…
Cancel
Save