MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / format_unchecked

Method format_unchecked

src/ore/src/sql.rs:235–261  ·  view source on GitHub ↗
(self, args: impl IntoIterator<Item = Sql>)

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 7

SqlClass · 0.85
expectMethod · 0.80
into_iterMethod · 0.45
lenMethod · 0.45
nextMethod · 0.45
pushMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected