From 15438313b8c9655871d6dc67bacfae70d7984396 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Fri, 20 Nov 2020 06:17:46 +0000 Subject: [PATCH 1/2] doubly-linked-list: Allow should_implement_trait It's understandable that clippy says the `next` here conflicts with Iterator's `next`, but I really think that's the best name for it unless we go with something like `forward` and `back`. There is one other example of Cursors on the internet: https://contain-rs.github.io/linked-list/linked_list/struct.Cursor.html This one also uses `next`, so it seems they did not find a better solution to this than we could. Helps address https://github.com/exercism/rust/pull/1011 Helps address https://github.com/exercism/rust/pull/1012 --- exercises/doubly-linked-list/example.rs | 1 + exercises/doubly-linked-list/src/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/exercises/doubly-linked-list/example.rs b/exercises/doubly-linked-list/example.rs index a46dd40ea..7ad602634 100644 --- a/exercises/doubly-linked-list/example.rs +++ b/exercises/doubly-linked-list/example.rs @@ -139,6 +139,7 @@ impl Cursor<'_, T> { } } + #[allow(clippy::should_implement_trait)] pub fn next(&mut self) -> Option<&mut T> { // safe as node.next is a valid potential pointer unsafe { self._step(|node| node.next) } diff --git a/exercises/doubly-linked-list/src/lib.rs b/exercises/doubly-linked-list/src/lib.rs index 68a82afc5..384d575e8 100644 --- a/exercises/doubly-linked-list/src/lib.rs +++ b/exercises/doubly-linked-list/src/lib.rs @@ -42,6 +42,7 @@ impl Cursor<'_, T> { unimplemented!() } + #[allow(clippy::should_implement_trait)] /// Move one position forward (towards the back) and /// return a reference to the new position pub fn next(&mut self) -> Option<&mut T> { From 2b61429157064de17767920b7fe1cfe0b818e9e6 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Fri, 20 Nov 2020 08:46:30 +0000 Subject: [PATCH 2/2] doubly-linked-list: attributes after comment Co-authored-by: Peter Goodspeed-Niklaus --- exercises/doubly-linked-list/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/doubly-linked-list/src/lib.rs b/exercises/doubly-linked-list/src/lib.rs index 384d575e8..2ecbc8bbf 100644 --- a/exercises/doubly-linked-list/src/lib.rs +++ b/exercises/doubly-linked-list/src/lib.rs @@ -42,9 +42,9 @@ impl Cursor<'_, T> { unimplemented!() } - #[allow(clippy::should_implement_trait)] /// Move one position forward (towards the back) and /// return a reference to the new position + #[allow(clippy::should_implement_trait)] pub fn next(&mut self) -> Option<&mut T> { unimplemented!() }