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,
85 pub writeable: T,
86}
87
88impl<T: Writeable + ?Sized> Writeable for WithPart<T> {
89 #[inline]
90 fn write_to<W: fmt::Write + ?Sized>(&self, sink: &mut W) -> fmt::Result {
91 self.writeable.write_to(sink)
92 }
93
94 #[inline]
95 fn write_to_parts<W: PartsWrite + ?Sized>(&self, sink: &mut W) -> fmt::Result {
96 sink.with_part(self.part, |w| self.writeable.write_to_parts(w))
97 }
98
99 #[inline]
100 fn writeable_length_hint(&self) -> LengthHint {
101 self.writeable.writeable_length_hint()
102 }
103
104 fn writeable_borrow(&self) -> Option<&str> {
105 self.writeable.writeable_borrow()
106 }
107
108 #[inline]
109 #[cfg(feature = "alloc")]
110 fn write_to_string(&self) -> Cow<'_, str> {
111 self.writeable.write_to_string()
112 }
113}
114
115impl<T: Writeable + ?Sized> fmt::Display for WithPart<T> {
116 #[inline]
117 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
118 Writeable::write_to(&self, f)
119 }
120}