Crates.io | non_structural_derive |
lib.rs | non_structural_derive |
version | |
source | src |
created_at | 2024-07-31 16:19:54.549546+00 |
updated_at | 2025-02-25 14:00:52.700999+00 |
description | nonstructural derives for auto traits |
homepage | |
repository | https://github.com/fee1-dead/non_structural_derive |
max_upload_size | |
id | 1321078 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | 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 |
non_structural_derive
A derive
-macro replacing the builtin auto-trait implementation with a manual non-recursive one:
struct Foo<T> {
a: Bar<T>,
b: Baz,
}
// The builtin auto-trait impl would look like this:
unsafe impl<T> Send for Foo<T>
where
Bar<T>: Send,
Baz: Send,
{}
// `#[non_structural_derive(Send)]` emits the the following instead:
unsafe impl<T: Send> Send for Foo<T> {}
fn _check_bound<T: Send>() {}
fn _validate_fields<T: Send>() {
_check_bound::<Bar<T>>();
_check_bound::<Baz>();
}
The code emitted by non_structural_derive
is strictly weaker than the builtin auto-trait impl.
It may however improve compile times and avoid overflow errors for very deeply nested types.