diff --git a/crates/loro-internal/src/loro.rs b/crates/loro-internal/src/loro.rs index 8a7c61db..f8f70a13 100644 --- a/crates/loro-internal/src/loro.rs +++ b/crates/loro-internal/src/loro.rs @@ -52,11 +52,18 @@ pub struct LoroDoc { arena: SharedArena, observer: Arc, diff_calculator: Arc>, + // when dropping the doc, the txn will be commited txn: Arc>>, auto_commit: bool, detached: bool, } +impl Default for LoroDoc { + fn default() -> Self { + Self::new() + } +} + impl LoroDoc { pub fn new() -> Self { let oplog = OpLog::new(); @@ -664,18 +671,6 @@ fn parse_encode_header(bytes: &[u8]) -> Result<(&[u8], EncodeMode), LoroError> { Ok((&input[1..], mode)) } -impl Default for LoroDoc { - fn default() -> Self { - Self::new() - } -} - -impl Drop for LoroDoc { - fn drop(&mut self) { - self.abort_txn(); - } -} - #[cfg(test)] mod test { use loro_common::ID;