From: Ian Jackson Date: Mon, 3 May 2021 13:01:12 +0000 (+0100) Subject: apitest: Allow reading OtterOutput to a string X-Git-Tag: otter-0.6.0~443 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=586f2b77e73c36287750a1a55b365d001cd793a8;p=otter.git apitest: Allow reading OtterOutput to a string Signed-off-by: Ian Jackson --- diff --git a/apitest/apitest.rs b/apitest/apitest.rs index 4a277c63..5bb53ad0 100644 --- a/apitest/apitest.rs +++ b/apitest/apitest.rs @@ -654,6 +654,15 @@ impl From for String { s } } +impl From<&mut OtterOutput> for String { + fn from(oo: &mut OtterOutput) -> String { + let mut s = String::new(); + let o = oo.output.as_mut().unwrap(); + o.rewind().unwrap(); + o.read_to_string(&mut s).unwrap(); + s + } +} impl Drop for OtterOutput { fn drop(&mut self) { if let Some(mut o) = self.output.take() {