Skip to content

Commit 329b8a3

Browse files
committed
Implement Ord by-hand instead of PartialOrd for Link
1 parent ccfbfe2 commit 329b8a3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/librustdoc/html/render/sidebar.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'a> LinkBlock<'a> {
7979
}
8080

8181
/// A link to an item. Content should not be escaped.
82-
#[derive(Ord, PartialEq, Eq, Hash, Clone)]
82+
#[derive(PartialEq, Eq, Hash, Clone)]
8383
pub(crate) struct Link<'a> {
8484
/// The content for the anchor tag and title attr
8585
name: Cow<'a, str>,
@@ -91,20 +91,26 @@ pub(crate) struct Link<'a> {
9191
children: Vec<Link<'a>>,
9292
}
9393

94-
impl PartialOrd for Link<'_> {
95-
fn partial_cmp(&self, other: &Link<'_>) -> Option<Ordering> {
94+
impl Ord for Link<'_> {
95+
fn cmp(&self, other: &Self) -> Ordering {
9696
match compare_names(&self.name, &other.name) {
97-
Ordering::Equal => (),
98-
result => return Some(result),
97+
Ordering::Equal => {}
98+
result => return result,
9999
}
100-
(&self.name_html, &self.href, &self.children).partial_cmp(&(
100+
(&self.name_html, &self.href, &self.children).cmp(&(
101101
&other.name_html,
102102
&other.href,
103103
&other.children,
104104
))
105105
}
106106
}
107107

108+
impl PartialOrd for Link<'_> {
109+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
110+
Some(self.cmp(other))
111+
}
112+
}
113+
108114
impl<'a> Link<'a> {
109115
pub fn new(href: impl Into<Cow<'a, str>>, name: impl Into<Cow<'a, str>>) -> Self {
110116
Self { href: href.into(), name: name.into(), children: vec![], name_html: None }

0 commit comments

Comments
 (0)