-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed some clippy warnings in libcollections #40541
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,7 @@ pub struct IterMut<'a, T: 'a> { | |
impl<'a, T: 'a + fmt::Debug> fmt::Debug for IterMut<'a, T> { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
f.debug_tuple("IterMut") | ||
.field(self.clone()) | ||
.field(self) | ||
.finish() | ||
} | ||
} | ||
|
@@ -111,7 +111,7 @@ pub struct IntoIter<T> { | |
impl<T: fmt::Debug> fmt::Debug for IntoIter<T> { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
f.debug_tuple("IntoIter") | ||
.field(self.clone()) | ||
.field(self) | ||
.finish() | ||
} | ||
} | ||
|
@@ -1020,8 +1020,8 @@ impl<I: IntoIterator> SpecExtend<I> for LinkedList<I::Item> { | |
} | ||
|
||
impl<T> SpecExtend<LinkedList<T>> for LinkedList<T> { | ||
fn spec_extend(&mut self, ref mut other: LinkedList<T>) { | ||
self.append(other); | ||
fn spec_extend(&mut self, mut other: LinkedList<T>) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rust doesn't implicitly copy things unless they are Copy, and heap-allocating collections are never Copy. Typical types that implement Copy are |
||
self.append(&mut other); | ||
} | ||
} | ||
|
||
|
@@ -1110,7 +1110,7 @@ pub struct FrontPlace<'a, T: 'a> { | |
impl<'a, T: 'a + fmt::Debug> fmt::Debug for FrontPlace<'a, T> { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
f.debug_tuple("FrontPlace") | ||
.field(self.clone()) | ||
.field(self) | ||
.finish() | ||
} | ||
} | ||
|
@@ -1165,7 +1165,7 @@ pub struct BackPlace<'a, T: 'a> { | |
impl<'a, T: 'a + fmt::Debug> fmt::Debug for BackPlace<'a, T> { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
f.debug_tuple("BackPlace") | ||
.field(self.clone()) | ||
.field(self) | ||
.finish() | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be
&mut other: BinaryHeap<T>
? I think you're forcing a copy here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is purely a coding style issue and both versions are equivalent. Rust doesn't implicitly copy things unless they are Copy. (Besides,
ref
andmut
are only applied to the parameter as a local variable, doesn't affect the function's signature.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can further clarify that yes, the BinaryHeap is consumed / moved into the method here. In the old code and new code. It's ultimately dictated by the Extend interface and not something that can be changed.