Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call rustfmt in manually generated code?

Tags:

rust

So I am generating bindings for a library and on top of that I'm generating most of the safe wrappers for that library.

The way I'm doing is simply generating a String with all the contents and writing to the file with the File trait...

I know the bindings crate supports formatting the generated code, but this particular one is not generated by it. Is there a way to make the build.rs call rustfmt on that generated file?

like image 520
Augusto Avatar asked Nov 18 '25 02:11

Augusto


1 Answers

I found out that rust bindgen uses a regular command call. I thought it was doing through some kind of rustfmt library. Reference: https://docs.rs/bindgen/0.51.1/src/bindgen/lib.rs.html#1945

like image 94
Augusto Avatar answered Nov 19 '25 19:11

Augusto