Skip to content

Commit 41a81ea

Browse files
Replace pop and pop_before with remove_current in Linked List Cusors
The name "pop" was critized in the discussion thread but despite agreement it should be changed, no one did. This commit implements basically the suggestion by Amanieu (but `remove_current` instead of `remove`). There is some discussion however, over if there should be two methods (differing in what element is the current one after deletion). This should be discussed in the tracking issue before stabilizing the feature.
1 parent b486793 commit 41a81ea

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

text/2570-linked-list-cursors.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn remove_replace<T, P, F>(list: &mut LinkedList<T>, p: P, f: F)
7171
None => break,
7272
};
7373
if should_replace {
74-
let old_element = cursor.pop().unwrap();
74+
let old_element = cursor.remove_current().unwrap();
7575
cursor.insert_after(f(old_element));
7676
}
7777
cursor.move_next();
@@ -171,10 +171,9 @@ impl<'list T> CursorMut<'list, T> {
171171
/// Insert `item` before the cursor
172172
pub fn insert_before(&mut self, item: T);
173173

174-
/// Remove and return the item following the cursor
175-
pub fn pop(&mut self) -> Option<T>;
176-
/// Remove and return the item before the cursor
177-
pub fn pop_before(&mut self) -> Option<T>;
174+
/// Remove the current item. The new current item is the item following the
175+
/// removed one.
176+
pub fn remove_current(&mut self) -> Option<T>;
178177

179178
/// Insert `list` between the current element and the next
180179
pub fn splice_after(&mut self, list: LinkedList<T>);

0 commit comments

Comments
 (0)