| 315 | /// Returns a possibly new SessionVar if this needs to mutate at transaction end. |
| 316 | #[must_use] |
| 317 | pub fn end_transaction(&self, action: EndTransactionAction) -> Option<Self> { |
| 318 | if !self.is_mutating() { |
| 319 | return None; |
| 320 | } |
| 321 | let mut next: Self = self.clone(); |
| 322 | next.local_value = None; |
| 323 | match action { |
| 324 | EndTransactionAction::Commit if next.staged_value.is_some() => { |
| 325 | next.session_value = next.staged_value.take() |
| 326 | } |
| 327 | _ => next.staged_value = None, |
| 328 | } |
| 329 | Some(next) |
| 330 | } |
| 331 | |
| 332 | /// Whether this Var needs to mutate at the end of a transaction. |
| 333 | pub fn is_mutating(&self) -> bool { |