1use crate::TryWriteable;
6use crate::Writeable;
7use core::fmt;
8
9#[derive(#[automatically_derived]
#[allow(clippy::exhaustive_structs)]
impl<A: ::core::fmt::Debug, B: ::core::fmt::Debug> ::core::fmt::Debug for
Concat<A, B> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Concat",
&self.0, &&self.1)
}
}Debug)]
53#[allow(clippy::exhaustive_structs)] pub struct Concat<A, B>(pub A, pub B);
55
56impl<A, B> Writeable for Concat<A, B>
57where
58 A: Writeable,
59 B: Writeable,
60{
61 #[inline]
62 fn write_to<W: fmt::Write + ?Sized>(&self, sink: &mut W) -> fmt::Result {
63 self.0.write_to(sink)?;
64 self.1.write_to(sink)
65 }
66 #[inline]
67 fn write_to_parts<S: crate::PartsWrite + ?Sized>(&self, sink: &mut S) -> fmt::Result {
68 self.0.write_to_parts(sink)?;
69 self.1.write_to_parts(sink)
70 }
71 #[inline]
72 fn writeable_length_hint(&self) -> crate::LengthHint {
73 self.0.writeable_length_hint() + self.1.writeable_length_hint()
74 }
75}
76
77impl<A, B, E> TryWriteable for Concat<A, B>
78where
79 A: TryWriteable<Error = E>,
80 B: TryWriteable<Error = E>,
81{
82 type Error = E;
83 #[inline]
84 fn try_write_to<W: fmt::Write + ?Sized>(
85 &self,
86 sink: &mut W,
87 ) -> Result<Result<(), Self::Error>, fmt::Error> {
88 if let Err(e) = self.0.try_write_to(sink)? {
89 return Ok(Err(e));
90 }
91 self.1.try_write_to(sink)
92 }
93 #[inline]
94 fn try_write_to_parts<S: crate::PartsWrite + ?Sized>(
95 &self,
96 sink: &mut S,
97 ) -> Result<Result<(), Self::Error>, fmt::Error> {
98 if let Err(e) = self.0.try_write_to_parts(sink)? {
99 return Ok(Err(e));
100 }
101 self.1.try_write_to_parts(sink)
102 }
103 #[inline]
104 fn writeable_length_hint(&self) -> crate::LengthHint {
105 self.0.writeable_length_hint() + self.1.writeable_length_hint()
106 }
107}
108
109impl<A, B> fmt::Display for Concat<A, B>
110where
111 A: Writeable,
112 B: Writeable,
113{
114 #[inline]
115 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
116 self.0.write_to(f)?;
117 self.1.write_to(f)
118 }
119}
120
121#[macro_export]
135#[doc(hidden)] macro_rules! __concat_writeable {
137 ($x:expr) => ($x);
139 ($x:expr, $($y:expr),+) => (
141 $crate::adapters::Concat($x, $crate::concat_writeable!($($y),+))
143 )
144}
145#[doc(inline)]
146pub use __concat_writeable as concat_writeable;