Crates.io | impl-for |
lib.rs | impl-for |
version | |
source | src |
created_at | 2024-05-21 07:33:47.925077 |
updated_at | 2024-10-27 03:22:03.080744 |
description | Macros to impl for multiple types |
homepage | |
repository | https://github.com/Bajix/impl-for/ |
max_upload_size | |
id | 1246492 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Macros for repeating implementations with type substitutions.
Before:
macro_rules! itoa_into_bytes {
($t:ty) => {
impl IntoBytes for $t {
fn into_bytes(self) -> Vec<u8> {
let mut buf = ::itoa::Buffer::new();
let s = buf.format(self);
s.as_bytes().to_vec()
}
}
};
}
itoa_into_bytes!(i8);
itoa_into_bytes!(u8);
itoa_into_bytes!(i16);
itoa_into_bytes!(u16);
itoa_into_bytes!(i32);
itoa_into_bytes!(u32);
itoa_into_bytes!(i64);
itoa_into_bytes!(u64);
itoa_into_bytes!(isize);
itoa_into_bytes!(usize);
After:
#[impl_for_each(i8, u8, i16, u16, i32, u32, i64, isize, usize)]
impl IntoBytes for T {
fn into_bytes(self) -> Vec<u8> {
let mut buf = ::itoa::Buffer::new();
let s = buf.format(self);
s.as_bytes().to_vec()
}
}