| 316 | /// you can call [`push_and_convert`](Self::push_and_convert) instead. |
| 317 | #[track_caller] |
| 318 | pub fn push<E>(&mut self, err: E) -> &mut StashWithErrors<I> |
| 319 | where |
| 320 | E: Into<I>, |
| 321 | { |
| 322 | // We need to move out of `&mut self` |
| 323 | // because we want to call `f()` which is `FnOnce()`. |
| 324 | |
| 325 | let mut swap = Self::WithErrors(StashWithErrors { |
| 326 | summary: String::new().into_boxed_str(), |
| 327 | errors: vec![], |
| 328 | locations: vec![], |
| 329 | }); |
| 330 | |
| 331 | core::mem::swap(self, &mut swap); |
| 332 | *self = ErrorStash::WithErrors(swap.push_and_convert(err)); |
| 333 | match self { |
| 334 | ErrorStash::Empty(_) => unreachable!(), |
| 335 | ErrorStash::WithErrors(stash_with_errors) => stash_with_errors, |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | /// Adds an error to this stash, |
| 340 | /// consumes `self`, and returns the inner [`StashWithErrors`] by value. |