#lifetime #author #force #annotations #require #write #proc-macro

macro require_lifetimes

A proc-macro to force rust authors to write lifetimes in function signatures

3 releases (breaking)

0.3.0 Jan 8, 2023
0.2.0 Jan 7, 2023
0.1.0 Jan 7, 2023

#1073 in Procedural macros

Download history 18/week @ 2024-07-17 25/week @ 2024-07-24 19/week @ 2024-07-31 14/week @ 2024-08-07 15/week @ 2024-08-14 12/week @ 2024-08-21 20/week @ 2024-08-28 8/week @ 2024-09-04 14/week @ 2024-09-11 94/week @ 2024-09-18 346/week @ 2024-09-25 205/week @ 2024-10-02 73/week @ 2024-10-09 16/week @ 2024-10-16 16/week @ 2024-10-23 13/week @ 2024-10-30

153 downloads per month

MIT/Apache

10KB
165 lines

Require Lifetimes

Require Lifetimes is a crate which provides the #[require_lifetimes] annotation. This annotation ensures that the annotated function must have lifetimes for every reference in its signature. In other words, it forces the author to not rely on lifetime elision for a given function. It also stops the author from using the anonymous lifetime '_.

The intent behind this crate is to force the user to actually understand lifetimes. This will be useful when teaching students how lifetimes work, or when trying to write explanatory material. This crate should not be used in production applications, as adding unnecessary lifetimes is an anti-pattern.

Examples

See the ui_tests folder for examples of programs with this annotation. Files ending in _err.rs_ have a corresponding .stderr that shows what their output will be.

Dependencies

~1.5MB
~37K SLoC