Compile-time lifetimes for comments.

Overview

todo_by

Compile-time lifetimes for comments.


To use this macro, add it to your dependencies via Cargo:

cargo add todo_by

Then, import and invoke the macro and add a date (such as above a function or statement) like so:

use todo_by::todo_by;

todo_by!("2023-06-01");
fn my_function() {
    // TODO: Implement this function by June 1st, 2023
}

If the current date is after June 1st, 2023, the macro will generate a compile error with the message “TODO by Jun 1, 2023 has passed”. If the current date is on or before June 1st, 2023, the macro will expand to nothing and the code will compile normally.

You can also add specific TODO comments:

todo_by!("2023-06-01", "Clean up implementation");

The todo_while macro allows you to ensure todos are done based on a semver requirement of what is in your Cargo.toml:

use todo_by::todo_while;

todo_while!("<1.0.0", "This has to be in the first major release")

This also allows you to make blockers:

todo_while!(">123.4", "Must fix this or bump the version")

Important note for library authors

Currently, if you publish/offer a crate and a todo_by expires in the lib code, then it would be an unfixable compilation error for anyone importing the crate. This problem is being investigated - please offer solutions if you have any!

You might find useful

Here're some alternative implementations for other languages and tools:

Comments
  • Adding version requirement macro

    Adding version requirement macro

    New macro todo_b4 will cause code to fail compilation if the version is Cargo.toml doesn't satisfy the requirement. e.g

    todo_b4!("<1.0.0", "Need to implement")
    
    opened by ACEnglish 29
  • Don't fail builds

    Don't fail builds

    One comment in particular on Reddit really hit me:

    RIP reproducible builds

    This has changed my perspective of a hard fail, even if they could just bump the date. There's also #1 to think about and solve, so making these not block the dependency tree goes hand in hand with making it a warning instead.

    The first step here is just adding #[cfg(test)] to the compile_error!() call. That "solves" the build problem pretty cleanly, in fact. As expected, when building a project I am not blocked. The editor still shows the compiler error when I hover over, which is nice. Tests with todo_by!() calls that have expired will fail. So the tests are still not completely solved because my dependencies could have todo_by!() calls that cause my tests to fail even though I didn't change anything. Not good.

    Screenshot 2023-05-14 at 5 37 10 PM Screenshot 2023-05-14 at 5 37 33 PM

    Since Macro Diagnostics are still not ready for Stable Rust, @Emilgardis showcased a workaround we can pull from where we pass the error message through a "deprecated" warning.

    I'm going to attempt to keep the compiler error in the editor (that's a nice visual reminder), but never have it run, even in tests. I'd rather just show the warnings, and even then I hope to be able to scope it to the current project and not show warnings from dependencies - that hopefully happens out of the box with deprecation warnings!

    opened by parker-codes 1
  • docs: added links to ESLint implementation to the readme

    docs: added links to ESLint implementation to the readme

    Hey hey -

    Fantastic work creating this package!

    I thought I'd suggest this tiny change, in case folks would be looking for JS/TS ecosystem implementations too. Hopefully, it makes sense and adds value, and is aligned with your vision regarding this project. If not - that's ok, no hard feelings.

    Let me know! 😉

    opened by maxprilutskiy 0
  • Make macro emit a warning instead of an error?

    Make macro emit a warning instead of an error?

    I believe it should be possible to emit a warning, using proc_macro::Diagnostic. With that in mind, I believe it'd be preferable to have the default behavior be to warn, and then opt in to it being an error.

    This also helps with #1, because when a dependency emits a warning Cargo silently ignores it.

    opened by Xaeroxe 3
  • Disable dependency errors (so only the current project is affected)

    Disable dependency errors (so only the current project is affected)

    Currently, if you publish/offer a crate and a todo_by expires in the lib code, then I believe it would be an unfixable compilation error for anyone importing the crate.

    Is there a way around this? Can we limit the context in which this compiler error shows?

    opened by parker-codes 7
Owner
Parker McMullin
Lead Frontend Engineer. Full-stack web developer.
Parker McMullin
Faster division by constants that aren't known at compile-time

Baseline implementation of division by constants When dividing integers by compile-time constants, compilers (LLVM) can be trusted to convert those to

Paul Khuong 18 Jul 6, 2022
This crate defines a single macro that is a brainfunct compile-time interpreter.

Compile Protection This crate defines a single macro that is a brainfunct compile-time interpreter. One example is as follows #![recursion_limit = "18

John Marsden 7 Nov 29, 2021
constduck: compile-time duck typing and reflection

constduck provides a procmacro that can enable compile time duck typing and reflection on arbitrary struct types.

ferrouille 15 Oct 12, 2022
Allocate memory at compile time!

const-alloc Link to the docs! Allocate memory at compile time! Currently, in stable rust there is no way to dynamically allocate or deallocate memory

Sp00ph 1 Feb 5, 2022
Option and Either types with variants known at compile time.

Const Either Some types to allow deciding at compile time if an option contains a value or which variant from the either type is active. This might be

null 1 May 5, 2022
A Rust proc-macro crate which derives functions to compile and parse back enums and structs to and from a bytecode representation

Bytecode A simple way to derive bytecode for you Enums and Structs. What is this This is a crate that provides a proc macro which will derive bytecode

null 4 Sep 3, 2022
little brother of gnu-copypasta-maker To compile, use make.

UWU Maker little brother of gnu-copypasta-maker To compile, use make. To install, use sudo make install or if you are root make install To uninstall,

Ahmet Efe AKYAZI 1 Jan 12, 2022
This is a Telegram bot I'm working on in my free time to learn Rust.

Maldness Bot This is a Telegram bot I'm working on in my free time to learn Rust. Building docker build -t . should be enough.

Sergey Kislyakov 10 May 13, 2022
Rust bindings for the KING OF TIME API

Rust bindings for the KING OF TIME API Example Prints if you are at work or not at work. $ cargo run --example tc -- status Record the time you start

Idein Inc. 2 Oct 11, 2021
A library to access BGPKIT Broker API and enable searching for BGP data archive files over time from public available data sources.

BGPKIT Broker BGPKIT Broker is a online data API service that allows users to search for publicly available BGP archive files by time, collector, proj

BGPKIT 10 Nov 30, 2022
Building a better screen reader for the Linux desktop, one step at a time.

Building a better screen reader for the Linux desktop, one step at a time.

Odilia 44 Dec 31, 2022
NSE is a rust cli binary and library for extracting real-time data from National Stock Exchange (India)

NSE Check out the sister projects NsePython and SaveKiteEnctoken which are Python & Javascript libraries to use the NSE and Zerodha APIs respectively

Techfane Technologies 4 Nov 28, 2022
A rust library for interacting with multiple Discord.com-compatible APIs and Gateways at the same time.

Chorus A rust library for interacting with (multiple) Spacebar-compatible APIs and Gateways (at the same time). Explore the docs » Report Bug · Reques

polyphony 4 Apr 30, 2023
languagetool-code-comments integrates the LanguageTool API to parse, spell check, and correct the grammar of your code comments!

languagetool-code-comments integrates the LanguageTool API to parse, spell check, and correct the grammar of your code comments! Overview Install MacO

Dustin Blackman 17 Dec 25, 2022
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
Like a cell, but make lifetimes dynamic instead of ownership

LendingCell is a mutable container that allows you to get an owned reference to the same object. When the owned reference is dropped, ownership return

Kalle Samuels 19 Dec 15, 2022
A question about lifetimes.

Lifetime annotations: why doesn't Rust? After having played a little with GATs and HKTs, I had a look at some of the exercises on https://practice.rs/

Massimiliano Tomassoli 16 Jan 23, 2023
An exploration of lifetimes in Rust.

LifetimeKata Welcome to LifetimeKata, a set of exercises which you can use to improve your understanding of lifetimes in Rust. While many tasks involv

Tom Kunc 22 Jan 23, 2023
`fugit` provides a comprehensive library of `Duration` and `Instant` for the handling of time in embedded systems, doing all it can at compile time.

fugit fugit provides a comprehensive library of Duration and Instant for the handling of time in embedded systems, doing all it can at compile time. T

Emil Fresk 40 Oct 2, 2022
An interactive scripting language where you can read and modify code comments as if they were regular strings

An interactive scripting language where you can read and modify code comments as if they were regular strings. Add and view text-based visualizations and debugging information inside your source code file.

Sumeet Agarwal 13 Apr 28, 2022