bookspec_checker/
files.rs1use include_dir::{Dir, include_dir};
6
7static EXAMPLES: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/../examples");
8static SPEC: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/../spec");
9
10fn texts(dir: &'static Dir<'static>, ext: &str) -> Vec<(&'static str, &'static str)> {
13 let mut out: Vec<_> = dir
14 .files()
15 .filter_map(|f| {
16 let name = f.path().file_name()?.to_str()?;
17 name.ends_with(ext)
18 .then(|| (name, f.contents_utf8().expect("a UTF-8 file")))
19 })
20 .collect();
21 out.sort();
22 out
23}
24
25#[must_use]
27pub fn examples() -> Vec<(&'static str, &'static str)> {
28 texts(&EXAMPLES, ".toml")
29}
30
31#[must_use]
34pub fn spec_files() -> Vec<(&'static str, &'static str)> {
35 texts(&SPEC, ".md")
36}