| Crates.io | non_structural_derive |
| lib.rs | non_structural_derive |
| version | 0.1.1 |
| 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 |
| size | 5,576 |
non_structural_deriveA 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.