Skip to content

Commit 1b0c662

Browse files
committed
process: inline TestWriterLock
1 parent b336179 commit 1b0c662

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

src/process/file_source.rs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -67,39 +67,16 @@ mod test_support {
6767

6868
// ----------------------- test support for writers ------------------
6969

70-
pub(in super::super) struct TestWriterLock<'a> {
71-
inner: MutexGuard<'a, Vec<u8>>,
72-
}
73-
74-
impl Write for TestWriterLock<'_> {
75-
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
76-
self.inner.write(buf)
77-
}
78-
79-
fn flush(&mut self) -> io::Result<()> {
80-
Ok(())
81-
}
82-
}
83-
8470
pub(in super::super) type TestWriterInner = Arc<Mutex<Vec<u8>>>;
8571

8672
/// A thread-safe test file handle that pretends to be e.g. stdout.
8773
#[derive(Clone, Default)]
8874
pub(in super::super) struct TestWriter(pub(in super::super) TestWriterInner);
8975

90-
impl TestWriter {
91-
pub(in super::super) fn lock(&self) -> TestWriterLock<'_> {
92-
// The stream can be locked even if a test thread panicked: its state
93-
// will be ok
94-
TestWriterLock {
95-
inner: self.0.lock().unwrap_or_else(|e| e.into_inner()),
96-
}
97-
}
98-
}
99-
10076
impl Write for TestWriter {
10177
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
102-
self.lock().write(buf)
78+
// The stream can be locked even if a test thread panicked: its state will be ok
79+
self.0.lock().unwrap_or_else(|e| e.into_inner()).write(buf)
10380
}
10481

10582
fn flush(&mut self) -> io::Result<()> {

0 commit comments

Comments
 (0)