non_structural_derive

Crates.ionon_structural_derive
lib.rsnon_structural_derive
version
sourcesrc
created_at2024-07-31 16:19:54.549546+00
updated_at2025-02-25 14:00:52.700999+00
descriptionnonstructural derives for auto traits
homepage
repositoryhttps://github.com/fee1-dead/non_structural_derive
max_upload_size
id1321078
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`
size0
lcnr (lcnr)

documentation

README

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>();
}

Why would you want this?

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.

Commit count: 0

cargo fmt