lib.rs 467 B

1234567891011121314151617181920
  1. use std::{
  2. fs::File,
  3. io::{self, Write},
  4. path::Path,
  5. };
  6. pub mod bindgen;
  7. pub mod generate;
  8. pub mod rustfmt;
  9. pub use generate::{generate, InputFile};
  10. pub fn write_to_file<T: AsRef<Path>>(path: T, code: &str) -> Result<(), io::Error> {
  11. let mut file = File::create(path)?;
  12. file.write_all(code.as_bytes())
  13. }
  14. pub fn write_to_file_fmt<T: AsRef<Path>>(path: T, code: &str) -> Result<(), io::Error> {
  15. write_to_file(path, &rustfmt::format(code)?)
  16. }