4 releases (2 breaking)

0.97.1 Aug 21, 2024
0.97.0 Aug 20, 2024
0.96.1 Jul 29, 2024
0.96.0 Jul 24, 2024
0.95.0 Jun 25, 2024

#1829 in Procedural macros

Download history 799/week @ 2024-06-21 750/week @ 2024-06-28 569/week @ 2024-07-05 533/week @ 2024-07-12 1099/week @ 2024-07-19 1437/week @ 2024-07-26 759/week @ 2024-08-02 778/week @ 2024-08-09 1221/week @ 2024-08-16 1154/week @ 2024-08-23 1041/week @ 2024-08-30

4,292 downloads per month
Used in 56 crates (via nu-protocol)

MIT license

49KB
698 lines

Macro implementations of #[derive(FromValue, IntoValue)].

As this crate is a proc_macro crate, it is only allowed to export procedural macros. Therefore, it only exports IntoValue and FromValue.

To get documentation for other functions and types used in this crate, run cargo doc -p nu-derive-value --document-private-items.

This crate uses a lot of proc_macro2::TokenStream as TokenStream2 to allow testing the behavior of the macros directly, including the output token stream or if the macro errors as expected. The tests for functionality can be found in nu_protocol::value::test_derive.

This documentation is often less reference-heavy than typical Rust documentation. This is because this crate is a dependency for nu_protocol, and linking to it would create a cyclic dependency. Also all examples in the documentation aren't tested as this crate cannot be compiled as a normal library very easily. This might change in the future if cargo allows building a proc-macro crate differently for cfg(doctest) as they are already doing for cfg(test).

The generated code from the derive macros tries to be as hygienic as possible. This ensures that the macro can be called anywhere without requiring specific imports. This results in obtuse code, which isn't recommended for manual, handwritten Rust but ensures that no other code may influence this generated code or vice versa.

Dependencies

~0.9–1.4MB
~27K SLoC