MCPcopy Index your code
hub / github.com/endbasic/endbasic / extract_propline

Function extract_propline

cli/src/propline.rs:81–100  ·  view source on GitHub ↗

Extracts the property line from `path` if present.

(path: P)

Source from the content-addressed store, hash-verified

79
80/// Extracts the property line from `path` if present.
81pub fn extract_propline<P: AsRef<Path>>(path: P) -> io::Result<PropLine> {
82 let input = File::open(path)?;
83 let mut input = BufReader::new(input);
84
85 let mut line1 = String::new();
86 if input.read_line(&mut line1)? == 0 {
87 return Ok(PropLine::default());
88 }
89 strip_newline(&mut line1);
90 if !line1.starts_with("#!") {
91 return Ok(PropLine::default());
92 }
93
94 let mut line2 = String::new();
95 if input.read_line(&mut line2)? == 0 {
96 return Ok(PropLine::default());
97 }
98 strip_newline(&mut line2);
99 parse_propline(&line2)
100}
101
102#[cfg(test)]
103mod tests {

Callers 2

app_mainFunction · 0.85
do_extractFunction · 0.85

Calls 2

strip_newlineFunction · 0.85
parse_proplineFunction · 0.85

Tested by

no test coverage detected