writeable/
parts_write_adapter.rs1use crate::*;
6
7#[derive(#[automatically_derived]
#[allow(clippy::exhaustive_structs)]
impl<W: ::core::fmt::Debug + fmt::Write + ?Sized> ::core::fmt::Debug for
CoreWriteAsPartsWrite<W> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"CoreWriteAsPartsWrite", &&self.0)
}
}Debug)]
9#[allow(clippy::exhaustive_structs)] pub struct CoreWriteAsPartsWrite<W: fmt::Write + ?Sized>(pub W);
11
12impl<W: fmt::Write + ?Sized> fmt::Write for CoreWriteAsPartsWrite<W> {
13 #[inline]
14 fn write_str(&mut self, s: &str) -> fmt::Result {
15 self.0.write_str(s)
16 }
17
18 #[inline]
19 fn write_char(&mut self, c: char) -> fmt::Result {
20 self.0.write_char(c)
21 }
22}
23
24impl<W: fmt::Write + ?Sized> PartsWrite for CoreWriteAsPartsWrite<W> {
25 type SubPartsWrite = CoreWriteAsPartsWrite<W>;
26
27 #[inline]
28 fn with_part(
29 &mut self,
30 _part: Part,
31 mut f: impl FnMut(&mut Self::SubPartsWrite) -> fmt::Result,
32 ) -> fmt::Result {
33 f(self)
34 }
35}
36
37#[derive(#[automatically_derived]
#[allow(clippy::exhaustive_structs)]
impl<T: ::core::fmt::Debug + ?Sized> ::core::fmt::Debug for WithPart<T> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "WithPart",
"part", &self.part, "writeable", &&self.writeable)
}
}Debug)]
82#[allow(clippy::exhaustive_structs)] pub struct WithPart<T: ?Sized> {
84 pub part: Part,
86 pub writeable: T,
88}
89
90impl<T: Writeable + ?Sized> Writeable for WithPart<T> {
91 #[inline]
92 fn write_to<W: fmt::Write + ?Sized>(&self, sink: &mut W) -> fmt::Result {
93 self.writeable.write_to(sink)
94 }
95
96 #[inline]
97 fn write_to_parts<W: PartsWrite + ?Sized>(&self, sink: &mut W) -> fmt::Result {
98 sink.with_part(self.part, |w| self.writeable.write_to_parts(w))
99 }
100
101 #[inline]
102 fn writeable_length_hint(&self) -> LengthHint {
103 self.writeable.writeable_length_hint()
104 }
105
106 fn writeable_borrow(&self) -> Option<&str> {
107 self.writeable.writeable_borrow()
108 }
109
110 #[inline]
111 #[cfg(feature = "alloc")]
112 fn write_to_string(&self) -> Cow<'_, str> {
113 self.writeable.write_to_string()
114 }
115}
116
117impl<T: Writeable + ?Sized> fmt::Display for WithPart<T> {
118 #[inline]
119 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
120 Writeable::write_to(&self, f)
121 }
122}