ByteLike Derive
ByteLike Derive is a procedural macro crate for deriving ByteLike functions for deriving byte-like new types.
It's a procedural macro that was created based off the implementation of Bytesize.
Usage
Add this to your Cargo.toml
[]
= { = "0.1" }
= { = "0.1", = ["serde"] }
= { = "1.0" }
= { = "1.0" }
Or if don't want serde:
[]
= { = "0.1" }
= { = "0.1" }
Next, define your new type and derive ByteLike for it:
use ByteLike;
;
Now you can do lots of useful byte-like things with your new type:
let new_type: NewType = "5KiB".parse.unwrap;
let other_type: NewType = kib;
let sum = new_type + other_type;