1 | // This file is part of ICU4X. For terms of use, please see the file |
---|---|
2 | // called LICENSE at the top level of the ICU4X source tree |
3 | // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). |
4 | |
5 | use crate::*; |
6 | |
7 | #[derive(Debug)] |
8 | #[allow(clippy::exhaustive_structs)] // newtype |
9 | pub struct CoreWriteAsPartsWrite<W: fmt::Write + ?Sized>(pub W); |
10 | |
11 | impl<W: fmt::Write + ?Sized> fmt::Write for CoreWriteAsPartsWrite<W> { |
12 | #[inline] |
13 | fn write_str(&mut self, s: &str) -> fmt::Result { |
14 | self.0.write_str(s) |
15 | } |
16 | |
17 | #[inline] |
18 | fn write_char(&mut self, c: char) -> fmt::Result { |
19 | self.0.write_char(c) |
20 | } |
21 | } |
22 | |
23 | impl<W: fmt::Write + ?Sized> PartsWrite for CoreWriteAsPartsWrite<W> { |
24 | type SubPartsWrite = CoreWriteAsPartsWrite<W>; |
25 | |
26 | #[inline] |
27 | fn with_part( |
28 | &mut self, |
29 | _part: Part, |
30 | mut f: impl FnMut(&mut Self::SubPartsWrite) -> fmt::Result, |
31 | ) -> fmt::Result { |
32 | f(self) |
33 | } |
34 | } |
35 |