Removes an element by ID. Returns the removed element if found.
(&mut self, id: &Id)
| 439 | /// |
| 440 | /// Returns the removed element if found. |
| 441 | pub fn remove(&mut self, id: &Id) -> Option<Id> { |
| 442 | if let Some(idx) = self.position(id) { |
| 443 | self.after_refs.remove(idx); |
| 444 | Some(self.elements.remove(idx)) |
| 445 | } else { |
| 446 | None |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | /// Clears all elements from the sequence. |
| 451 | #[inline] |