chore: Fix some violations of 'needless_pass_by_ref_mut' lint (#18795)

While this lint is allow-by-default, it seems pretty useful to get rid
of mutable borrows when they're not needed.

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-10-07 01:29:58 +02:00 committed by GitHub
parent 59f0f4ac42
commit 03c84466c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 158 additions and 204 deletions

View file

@ -71,7 +71,7 @@ impl Markdown {
source: String,
style: MarkdownStyle,
language_registry: Option<Arc<LanguageRegistry>>,
cx: &mut ViewContext<Self>,
cx: &ViewContext<Self>,
fallback_code_block_language: Option<String>,
) -> Self {
let focus_handle = cx.focus_handle();
@ -97,7 +97,7 @@ impl Markdown {
source: String,
style: MarkdownStyle,
language_registry: Option<Arc<LanguageRegistry>>,
cx: &mut ViewContext<Self>,
cx: &ViewContext<Self>,
fallback_code_block_language: Option<String>,
) -> Self {
let focus_handle = cx.focus_handle();
@ -119,12 +119,12 @@ impl Markdown {
this
}
pub fn append(&mut self, text: &str, cx: &mut ViewContext<Self>) {
pub fn append(&mut self, text: &str, cx: &ViewContext<Self>) {
self.source.push_str(text);
self.parse(cx);
}
pub fn reset(&mut self, source: String, cx: &mut ViewContext<Self>) {
pub fn reset(&mut self, source: String, cx: &ViewContext<Self>) {
if source == self.source() {
return;
}
@ -145,7 +145,7 @@ impl Markdown {
&self.parsed_markdown
}
fn copy(&self, text: &RenderedText, cx: &mut ViewContext<Self>) {
fn copy(&self, text: &RenderedText, cx: &ViewContext<Self>) {
if self.selection.end <= self.selection.start {
return;
}
@ -153,7 +153,7 @@ impl Markdown {
cx.write_to_clipboard(ClipboardItem::new_string(text));
}
fn parse(&mut self, cx: &mut ViewContext<Self>) {
fn parse(&mut self, cx: &ViewContext<Self>) {
if self.source.is_empty() {
return;
}
@ -319,7 +319,7 @@ impl MarkdownElement {
}
fn paint_selection(
&mut self,
&self,
bounds: Bounds<Pixels>,
rendered_text: &RenderedText,
cx: &mut WindowContext,
@ -382,7 +382,7 @@ impl MarkdownElement {
}
fn paint_mouse_listeners(
&mut self,
&self,
hitbox: &Hitbox,
rendered_text: &RenderedText,
cx: &mut WindowContext,
@ -487,7 +487,7 @@ impl MarkdownElement {
});
}
fn autoscroll(&mut self, rendered_text: &RenderedText, cx: &mut WindowContext) -> Option<()> {
fn autoscroll(&self, rendered_text: &RenderedText, cx: &mut WindowContext) -> Option<()> {
let autoscroll_index = self
.markdown
.update(cx, |markdown, _| markdown.autoscroll_request.take())?;