Janitor: Fix clippy::map_clone

This commit is contained in:
Tobias Hunger 2021-08-04 22:02:54 +02:00 committed by Olivier Goffart
parent 0d73917526
commit 04738a900f
3 changed files with 4 additions and 4 deletions

View file

@ -483,7 +483,7 @@ declare_types! {
method show(mut cx) {
let this = cx.this();
let window = cx.borrow(&this, |x| x.0.as_ref().map(|c| c.clone()));
let window = cx.borrow(&this, |x| x.0.as_ref().cloned());
let window = window.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?;
window.show();
Ok(JsUndefined::new().as_value(&mut cx))
@ -491,7 +491,7 @@ declare_types! {
method hide(mut cx) {
let this = cx.this();
let window = cx.borrow(&this, |x| x.0.as_ref().map(|c| c.clone()));
let window = cx.borrow(&this, |x| x.0.as_ref().cloned());
let window = window.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?;
window.hide();
Ok(JsUndefined::new().as_value(&mut cx))

View file

@ -1367,7 +1367,7 @@ unsafe extern "C" fn parent_item(component: ComponentRefPin, index: usize, resul
.original
.parent_element
.upgrade()
.and_then(|e| e.borrow().item_index.get().map(|x| *x));
.and_then(|e| e.borrow().item_index.get().cloned());
if let (Some(parent_offset), Some(parent_index)) =
(instance_ref.component_type.parent_component_offset, parent_item_index)
{

View file

@ -188,7 +188,7 @@ pub fn set_contents(path: &Path, content: String) {
/// In any was, register it as a dependency
fn get_file_from_cache(path: PathBuf) -> Option<String> {
let mut cache = CONTENT_CACHE.get_or_init(Default::default).lock().unwrap();
let r = cache.source_code.get(&path).map(|r| r.clone());
let r = cache.source_code.get(&path).cloned();
cache.dependency.insert(path);
r
}