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

feat: Added support for the unit type ('()'). #11

Closed ckaran closed 2 years ago

ckaran commented 2 years ago

Added support for the unit (()) type, which is a zero-sized type. As you'd expect, this neither reads nor writes to the underlying storage. The main purpose for this is for derive macros which may require that all elements of a struct also implement the various traits. Basically, this is a partial answer to #9.

codecov-commenter commented 2 years ago

Codecov Report

Merging #11 (682731b) into master (bc9a29d) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #11   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            5         5           
  Lines         1288      1328   +40     
=========================================
+ Hits          1288      1328   +40     
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 e019ecd...682731b. Read the comment docs.

ckaran commented 2 years ago

add a changelog entry

Whoops, my bad! Thank you for catching that.

add a unit test somewhere that includes a zero sized type in an actual define_layout! invocation. I could imagine parentheses screwing up the macro somehow.

Done

smessmer commented 2 years ago

Thank you :)