smessmer / binary-layout

The binary-layout library allows type-safe, inplace, zero-copy access to structured binary data. You define a custom data layout and give it a slice of binary data, and it will allow you to read and write the fields defined in the layout from the binary data without having to copy any of the data. It's similar to transmuting to/from a #[repr(packed)] struct, but much safer.
Apache License 2.0
66 stars 9 forks source link

Add f32/f64 support #8

Closed ckaran closed 2 years ago

ckaran commented 2 years ago

PR for #6

codecov-commenter commented 2 years ago

Codecov Report

Merging #8 (62a6229) into master (676777e) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            master        #8    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files            5         5            
  Lines         1153      1288   +135     
==========================================
+ Hits          1153      1288   +135     
Impacted Files Coverage Δ
src/lib.rs 100.00% <ø> (ø)
src/fields/primitive.rs 100.00% <100.00%> (ø)
src/fields/wrapped.rs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 676777e...62a6229. Read the comment docs.

ckaran commented 2 years ago

I have no idea why rustfmt would fail... weird!

smessmer commented 2 years ago

Thanks :) The rustfmt check is weird, likely a CI misconfiguration. Let's see if it passes after it't in master.

smessmer commented 2 years ago

Looks like it passed on master. CI is configured in a way that automatically runs rustfmt and creates and pushes a commit with the fixes. It just did that to master: https://github.com/smessmer/binary-layout/commit/e019ecddd27531ff82b3f235f4b40521574b9648

But the CI job likely didn't have permissions to push the fixes to your branch, that's why it failed.

ckaran commented 2 years ago

Got it. Do you have a .rustfmt.toml file that you use normally that you'd be willing to add to the repository? I can go ahead and format my PRs using it, if you wish. Otherwise when I format I'll be using my .rustfmt.toml file, which is probably not what you want.

smessmer commented 2 years ago

The project just uses the rustfmt defaults. I added an empty rustfmt.toml to master, hope that does it.

ckaran commented 2 years ago

Yup, just saw it when I merged your repository into mine. I've got a tiny shell script (see below) that I use to clean up my commits before I make them, once my outstanding PRs are merged in, I'll run it across the code and make another PR. That way you don't have to sort out reviewing the formatting from reviewing actual substantive changes.

Scripts

I use a pair of scripts, trim_rust.sh and preen_rust.sh, with the latter calling the former.

trim_rust.sh

#!/bin/sh

find . -name '*.rs' -exec sed -i "s/[[:blank:]]*$//" {} \;

preen_rust.sh

#!/bin/sh

cargo +nightly fmt --all && trim_rust.sh