compiletest/directives/file.rs
1use camino::Utf8Path;
2
3use crate::directives::line::{DirectiveLine, line_directive};
4
5pub(crate) struct FileDirectives<'a> {
6 pub(crate) path: &'a Utf8Path,
7 pub(crate) lines: Vec<DirectiveLine<'a>>,
8}
9
10impl<'a> FileDirectives<'a> {
11 pub(crate) fn from_file_contents(path: &'a Utf8Path, file_contents: &'a str) -> Self {
12 let mut lines = vec![];
13
14 for (line_number, ln) in (1..).zip(file_contents.lines()) {
15 let ln = ln.trim();
16
17 if let Some(directive_line) = line_directive(line_number, ln) {
18 lines.push(directive_line);
19 }
20 }
21
22 Self { path, lines }
23 }
24}