fix: compile error when using enum in flutter

This commit is contained in:
SoLongAndThanksForAllThePizza
2022-05-31 16:28:12 +08:00
parent 00ba7cad81
commit 5825ae4531
59 changed files with 6133 additions and 87 deletions
@@ -0,0 +1,26 @@
use std::fs;
use std::path::Path;
pub fn mod_from_rust_path(code_path: &str, crate_path: &str) -> String {
Path::new(code_path)
.strip_prefix(Path::new(crate_path).join("src"))
.unwrap()
.with_extension("")
.into_os_string()
.into_string()
.unwrap()
.replace('/', "::")
}
pub fn with_changed_file<F: FnOnce() -> anyhow::Result<()>>(
path: &str,
append_content: &str,
f: F,
) -> anyhow::Result<()> {
let content_original = fs::read_to_string(&path)?;
fs::write(&path, content_original.clone() + append_content)?;
f()?;
Ok(fs::write(&path, content_original)?)
}