(&mut self, closure: impl FnOnce(&mut Self) -> Transaction<T>)
| 428 | } |
| 429 | |
| 430 | pub fn in_transaction<T>(&mut self, closure: impl FnOnce(&mut Self) -> Transaction<T>) -> T { |
| 431 | let snapshot = self.imports.start_snapshot(); |
| 432 | |
| 433 | let transaction = closure(self); |
| 434 | |
| 435 | match transaction { |
| 436 | Transaction::Commit(value) => { |
| 437 | self.imports.commit(snapshot); |
| 438 | |
| 439 | value |
| 440 | } |
| 441 | Transaction::Rollback(value) => { |
| 442 | self.imports.rollback_to(snapshot); |
| 443 | |
| 444 | value |
| 445 | } |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | #[cfg(test)] |
| 450 | pub(crate) fn imports_as_slice(&self) -> &[Import<'heap>] { |
nothing calls this directly
no test coverage detected