| 233 | /// violations as errors. |
| 234 | #[doc(hidden)] |
| 235 | pub fn format_unchecked(self, args: impl IntoIterator<Item = Sql>) -> Self { |
| 236 | let mut args = args.into_iter(); |
| 237 | let mut out = String::with_capacity(self.0.len()); |
| 238 | let mut chars = self.0.chars().peekable(); |
| 239 | |
| 240 | while let Some(ch) = chars.next() { |
| 241 | match ch { |
| 242 | '{' => match chars.next().expect("validated in sql! macro") { |
| 243 | '{' => out.push('{'), |
| 244 | '}' => { |
| 245 | let arg = args.next().expect("validated in sql! macro"); |
| 246 | out.push_str(arg.as_str()); |
| 247 | } |
| 248 | _ => unreachable!("validated in sql! macro"), |
| 249 | }, |
| 250 | '}' => match chars.next().expect("validated in sql! macro") { |
| 251 | '}' => out.push('}'), |
| 252 | _ => unreachable!("validated in sql! macro"), |
| 253 | }, |
| 254 | _ => out.push(ch), |
| 255 | } |
| 256 | } |
| 257 | if cfg!(debug_assertions) { |
| 258 | assert!(args.next().is_none(), "validated in sql! macro"); |
| 259 | } |
| 260 | Sql(Cow::Owned(out)) |
| 261 | } |
| 262 | |
| 263 | /// Returns the underlying SQL string. |
| 264 | pub fn as_str(&self) -> &str { |