From 5c510990d11384b16749b865bbf533e5dfd82e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Kriv=C3=A1cs=20Schr=C3=B8der?= Date: Wed, 13 Jul 2022 10:20:58 +0200 Subject: [PATCH] Add methods to get access to the wrapped `Write` reference. --- src/lib.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index f9b73ba..cd1ff53 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -319,6 +319,24 @@ impl<'a, T: fmt::Write> CodeFormatter<'a, T> { } } +#[cfg(feature = "std")] +impl<'a, T> CodeFormatter<'a, T> { + /// Get a reference to the inner `T` + pub fn inner_ref(&self) -> &T { + self.f + } + + /// Get a mutable reference to the inner `T` + pub fn inner_mut(&mut self) -> &mut T { + self.f + } + + /// Get back the original mutable reference to the inner `T` + pub fn into_inner(self) -> &'a mut T { + self.f + } +} + #[cfg(test)] mod tests { extern crate alloc;