Avoid unnecessary borrows
This patch removes unnecessary borrows of references that are automatically removed by the compiler. This takes care of the new clippy lint needless_borrow.
This commit is contained in:
parent
637338cde5
commit
88385fe1db
@ -235,7 +235,7 @@ impl Index {
|
||||
None => path.to_owned(),
|
||||
};
|
||||
let full_name: doc::Fqn = format!("{}::{}", &full_path, &item.name).into();
|
||||
if full_name.ends_with(&name) {
|
||||
if full_name.ends_with(name) {
|
||||
log::info!("Found index match '{}'", full_name);
|
||||
matches.push(IndexItem {
|
||||
name: full_name,
|
||||
|
@ -447,7 +447,7 @@ fn get_method_groups(
|
||||
if let Some(title) = subheading.first_child() {
|
||||
if let Some(impl_items) = subheading.next_sibling() {
|
||||
if let Some(group) =
|
||||
get_impl_items(parent, &title, &impl_items, ty, &subheading_type)?
|
||||
get_impl_items(parent, &title, &impl_items, ty, subheading_type)?
|
||||
{
|
||||
groups.push(group);
|
||||
}
|
||||
@ -463,7 +463,7 @@ fn get_method_groups(
|
||||
if let Some(title) = h3.and_then(|n| n.first_child()) {
|
||||
if let Some(impl_items) = summary.and_then(|n| n.next_sibling()) {
|
||||
if let Some(group) =
|
||||
get_impl_items(parent, &title, &impl_items, ty, &subheading_type)?
|
||||
get_impl_items(parent, &title, &impl_items, ty, subheading_type)?
|
||||
{
|
||||
groups.push(group);
|
||||
}
|
||||
@ -486,7 +486,7 @@ fn get_impl_items(
|
||||
) -> anyhow::Result<Option<doc::MemberGroup>> {
|
||||
let title = title.text_contents();
|
||||
if impl_items.is_element(&local_name!("div")) && impl_items.has_class("impl-items") {
|
||||
get_method_group(parent, Some(title), &impl_items, ty, &subheading_type)
|
||||
get_method_group(parent, Some(title), impl_items, ty, subheading_type)
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
|
@ -88,19 +88,19 @@ impl DirSource {
|
||||
) -> anyhow::Result<Option<doc::Doc>> {
|
||||
if let Some(ty) = ty {
|
||||
match ty {
|
||||
doc::ItemType::Module => self.get_module(&path, name),
|
||||
doc::ItemType::Module => self.get_module(path, name),
|
||||
doc::ItemType::StructField
|
||||
| doc::ItemType::Variant
|
||||
| doc::ItemType::AssocType
|
||||
| doc::ItemType::AssocConst
|
||||
| doc::ItemType::Method => self.get_member(&path, name),
|
||||
_ => self.get_item(&path, name),
|
||||
| doc::ItemType::Method => self.get_member(path, name),
|
||||
_ => self.get_item(path, name),
|
||||
}
|
||||
} else {
|
||||
self.get_item(&path, name)
|
||||
self.get_item(path, name)
|
||||
.transpose()
|
||||
.or_else(|| self.get_module(&path, name).transpose())
|
||||
.or_else(|| self.get_member(&path, name).transpose())
|
||||
.or_else(|| self.get_module(path, name).transpose())
|
||||
.or_else(|| self.get_member(path, name).transpose())
|
||||
.transpose()
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ pub fn spawn_pager(args: &args::ViewerArgs) {
|
||||
env::set_var("LESS", "cR");
|
||||
}
|
||||
let mut pager = if let Some(pager) = &args.pager {
|
||||
pager::Pager::with_pager(&pager)
|
||||
pager::Pager::with_pager(pager)
|
||||
} else {
|
||||
pager::Pager::with_default_pager("less")
|
||||
};
|
||||
|
@ -40,7 +40,7 @@ impl TuiViewer {
|
||||
F: Fn(&mut TuiManRenderer) -> Result<(), convert::Infallible>,
|
||||
{
|
||||
let mut s = create_cursive(sources, args)?;
|
||||
let mut renderer = context(&mut s).create_renderer(&doc);
|
||||
let mut renderer = context(&mut s).create_renderer(doc);
|
||||
f(&mut renderer)?;
|
||||
let view = renderer.into_view();
|
||||
s.add_fullscreen_layer(view);
|
||||
@ -341,8 +341,8 @@ fn select_doc_dialog(s: &mut cursive::Cursive, items: Vec<index::IndexItem>) {
|
||||
}
|
||||
|
||||
fn open_doc(s: &mut cursive::Cursive, doc: &doc::Doc) {
|
||||
let mut renderer = context(s).create_renderer(&doc);
|
||||
renderer.render_doc(&doc).unwrap();
|
||||
let mut renderer = context(s).create_renderer(doc);
|
||||
renderer.render_doc(doc).unwrap();
|
||||
let view = renderer.into_view();
|
||||
s.add_fullscreen_layer(view);
|
||||
}
|
||||
@ -434,7 +434,7 @@ fn resolve_doc_link(
|
||||
// part == "type.name.html"
|
||||
ty = Some(part_ty.parse()?);
|
||||
name = if let Some(name) = name {
|
||||
Some(name.child(&part_name))
|
||||
Some(name.child(part_name))
|
||||
} else {
|
||||
Some(part_name.to_owned().into())
|
||||
};
|
||||
@ -442,7 +442,7 @@ fn resolve_doc_link(
|
||||
// part == "<module>"
|
||||
ty = Some(doc::ItemType::Module);
|
||||
name = if let Some(name) = name {
|
||||
Some(name.child(&part))
|
||||
Some(name.child(part))
|
||||
} else {
|
||||
Some(part.to_owned().into())
|
||||
};
|
||||
@ -457,7 +457,7 @@ fn resolve_doc_link(
|
||||
if let Some((fragment_ty, fragment_name)) = parse_url_part(fragment, None) {
|
||||
ty = Some(fragment_ty.parse()?);
|
||||
name = if let Some(name) = name {
|
||||
Some(name.child(&fragment_name))
|
||||
Some(name.child(fragment_name))
|
||||
} else {
|
||||
Some(fragment_name.to_owned().into())
|
||||
};
|
||||
|
@ -71,7 +71,7 @@ impl<'s, 'ss, 't, I: Iterator<Item = &'s str>> Iterator for HighlightedLines<'s,
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.iter
|
||||
.next()
|
||||
.map(|s| self.highlighter.highlight(s, &self.syntax_set))
|
||||
.map(|s| self.highlighter.highlight(s, self.syntax_set))
|
||||
}
|
||||
}
|
||||
|
||||
@ -445,7 +445,7 @@ pub fn get_highlighter(args: &args::ViewerArgs) -> anyhow::Result<Option<Highlig
|
||||
if args.no_syntax_highlight {
|
||||
Ok(None)
|
||||
} else {
|
||||
Highlighter::new(&args).map(Some)
|
||||
Highlighter::new(args).map(Some)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user