Skip to content

Commit 1760c62

Browse files
committed
Add methods for replacing the contents of a BufferQueue.
1 parent 82ede61 commit 1760c62

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

markup5ever/util/buffer_queue.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//!
1919
//! [`BufferQueue`]: struct.BufferQueue.html
2020
21-
use std::{cell::RefCell, collections::VecDeque};
21+
use std::{cell::RefCell, collections::VecDeque, mem};
2222

2323
use tendril::StrTendril;
2424

@@ -235,6 +235,14 @@ impl BufferQueue {
235235

236236
result
237237
}
238+
239+
pub fn replace_with(&self, other: BufferQueue) {
240+
let _ = mem::replace(&mut *self.buffers.borrow_mut(), other.buffers.take());
241+
}
242+
243+
pub fn swap_with(&self, other: &BufferQueue) {
244+
mem::swap(&mut *self.buffers.borrow_mut(), &mut *other.buffers.borrow_mut());
245+
}
238246
}
239247

240248
#[cfg(test)]

0 commit comments

Comments
 (0)