MCPcopy Create free account
hub / github.com/PRQL/prql / WriteSource

Interface WriteSource

prqlc/prqlc/src/codegen/mod.rs:7–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5mod types;
6
7pub trait WriteSource {
8 /// Converts self to its source representation according to specified
9 /// options.
10 ///
11 /// Returns `None` if source does not fit into [WriteOpt::rem_width].
12 fn write(&self, opt: WriteOpt) -> Option<String>;
13
14 fn write_between<S: ToString>(
15 &self,
16 prefix: S,
17 suffix: &str,
18 mut opt: WriteOpt,
19 ) -> Option<String> {
20 let mut r = String::new();
21 r += opt.consume(&prefix.to_string())?;
22 opt.context_strength = 0;
23 opt.unbound_expr = false;
24
25 let source = self.write(opt.clone())?;
26 r += opt.consume(&source)?;
27
28 r += opt.consume(suffix)?;
29 Some(r)
30 }
31
32 fn write_or_expand(&self, mut opt: WriteOpt) -> String {
33 loop {
34 if let Some(s) = self.write(opt.clone()) {
35 return s;
36 } else {
37 opt.max_width += opt.max_width / 2;
38 opt.reset_line();
39 }
40 }
41 }
42}
43
44impl<T: WriteSource> WriteSource for &T {
45 fn write(&self, opt: WriteOpt) -> Option<String> {

Callers 3

writeMethod · 0.80
writeMethod · 0.80
writeMethod · 0.80

Implementers 3

mod.rsprqlc/prqlc/src/codegen/mod.rs
types.rsprqlc/prqlc/src/codegen/types.rs
ast.rsprqlc/prqlc/src/codegen/ast.rs

Calls

no outgoing calls

Tested by

no test coverage detected