Joins SQL fragments with a static separator.
(parts: impl IntoIterator<Item = Sql>, separator: &'static str)
| 167 | |
| 168 | /// Joins SQL fragments with a static separator. |
| 169 | pub fn join(parts: impl IntoIterator<Item = Sql>, separator: &'static str) -> Self { |
| 170 | let mut iter = parts.into_iter(); |
| 171 | let Some(first) = iter.next() else { |
| 172 | return Self(Cow::Borrowed("")); |
| 173 | }; |
| 174 | |
| 175 | let mut out = first.0; |
| 176 | for part in iter { |
| 177 | out.to_mut().push_str(separator); |
| 178 | out.to_mut().push_str(part.as_str()); |
| 179 | } |
| 180 | Self(out) |
| 181 | } |
| 182 | |
| 183 | /// Formats this SQL fragment by replacing each `{}` with the next SQL argument. |
| 184 | /// |