Skip to content

Commit 61ac8d6

Browse files
committed
Rust: make things compile
1 parent fabdb3c commit 61ac8d6

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/generate-schema/src/codegen.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pub mod grammar;
2+
3+
pub fn reformat(x: String) -> String {
4+
x
5+
}
6+
7+
pub fn add_preamble(_x: crate::flags::CodegenType, y: String) -> String {
8+
y
9+
}
10+
pub fn ensure_file_contents(
11+
_x: crate::flags::CodegenType,
12+
path: &std::path::Path,
13+
contents: &String,
14+
_check: bool,
15+
) {
16+
std::fs::write(path, contents).expect("Unable to write file");
17+
}

rust/generate-schema/src/flags.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use std::fmt::Display;
2+
3+
pub enum CodegenType {
4+
Grammar,
5+
}
6+
7+
impl Display for CodegenType {
8+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9+
write!(f, "Grammar")
10+
}
11+
}

rust/generate-schema/src/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use std::path::PathBuf;
2+
3+
mod codegen;
4+
mod flags;
5+
use std::env;
6+
7+
fn project_root() -> PathBuf {
8+
let dir =
9+
env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| env!("CARGO_MANIFEST_DIR").to_owned());
10+
PathBuf::from(dir).parent().unwrap().to_owned()
11+
}
12+
fn main() {}

0 commit comments

Comments
 (0)