This is essentially a ref-aware fork of Clippy’s redundant_closure_for_method_calls
lint. It suggests to remove a closure when made possible by a use of as_ref
, as_mut
,
as_deref
, or as_deref_mut
.
Currently works only for Option
s.
Some(String::from("a")).map(|s| s.is_empty());
Some(String::from("a")).map(|s| s.to_uppercase());
Use instead:
Some(String::from("a")).as_ref().map(String::is_empty);
Some(String::from("a")).as_deref().map(str::to_uppercase);