lit-robotics / libcamera-rs

Experimental Rust bindings for libcamera
Apache License 2.0
51 stars 16 forks source link

Add rustfmt options and format codebase #14

Closed mfreeborn closed 1 year ago

mfreeborn commented 1 year ago

Without wishing to bikeshed too much, I think adding a couple of extra options to rustfmt.toml can be quite useful as the project grows. Mainly I've added import sorting and comment formatting (which matches the width of the lines of source code). I've ignored the generated modules for now.

To run on the command line, this needs cargo +nightly fmt if your default toolchain is stable, but note that it doesn't mean nightly is required to build the library or for any other reason.

To appease VScode, one can add

"rust-analyzer.rustfmt.extraArgs": [
    "+nightly"
],

to settings.json.

mfreeborn commented 1 year ago

Please just squash all these commits away... incidentally, I'm not sure RUSTFLAGS: "-Dwarnigns" does anything for cargo doc? At least, it reports Found argument '-D' which wasn't expected, or isn't valid in this context when passed inline.

chemicstry commented 1 year ago

I think these options are fine for now. Thanks.

I'm not sure RUSTFLAGS: "-Dwarnigns" does anything for cargo doc? At least, it reports Found argument '-D' which wasn't expected, or isn't valid in this context when passed inline.

My bad, I wanted to promote cargo doc warnings to errors, but it seems it uses different env RUSTDOCFLAGS='-D warnings'.