todo2(a.k.a. todo or die) - A better todo! macro inspired from searls/todo_or_die

Overview

todo2

todo2(a.k.a. todo or die) - A better todo! macro inspired from searls/todo_or_die

crates.io docs.rs downloads license

This crate provides a better todo! macro, which allows you to specify the deadline and the condition when the code should be implemented. and when the condition or the deadline is met, the code will panic or emit a compile error, or just log an error.

Note: this crate is still in the early development, so it may have some bugs, and the API may change in the future. If you have any suggestions or you found a bug, please open an issue or a pull request.

Usage

Add this to your Cargo.toml:

[dependencies]
todo2 = "0.1.0"

or just run this command:

cargo add todo2
#[macro_use]
extern crate todo2;

fn main() {
  todo!("Hack NASA", by: 2024-3-26 at 9:00);
  get_a_hot_gf(true)
}

fn get_a_hot_gf(single: bool) {
 todo!("Get a hot girlfriend", if: single);
}

Features

  • log - Just logs an error instead of panicking or emitting a compile error, this may useful in the serious projects, this feature respects that you have added the log crate to your dependencies
  • compile-error - Emits a compile error instead of panicking.
  • with-chrono - Enables the chrono this enables you to specify the deadline for the by condition using the chrono::Utc or chrono::DateTime types. not implemented yet
  • with-time - Enables the time this enables you to specify the deadline for the by condition using the time::OffsetDateTime type or the time::macros::datetime macro. not implemented yet
  • and-time - allows you to specify a specific time of the day in the by condition
  • original-compatibility - Allows you to use this macro without pass any arguments, or with only the message.
  • strict-syntax - Enables the strict syntax,, just too force you to put a comma or a semicolon after the message.
  • chrono-backend - Use the chrono as the backend instead of the default implementation for the by condition to calculate the unix time stamp. I prefer to enable this feature if I have chrono in the dependencies, because it's more accurate than the default implementation. Read more
  • time-backend - Use the time as the backend instead of the default implementation for the by condition to calculate the unix time stamp. I prefer to enable this feature if I have time in the dependencies, because it's more accurate than the default implementation. Read more
  • am-cool - To indicate that you are cool. I love you.

The default features are: original-compatibility, strict-syntax, and-time, time-backend.

Examples

Using the log feature

You have to enable the log feature in your Cargo.toml:

[dependencies]
# You also have to add the `log` crate to your dependencies
log = "0.4.20"
# Use any implementation you want for the logging, in this example, I will use the `simple_logger` crate
simple_logger = "4.2.0"
# and of course, our beloved `todo2` crate
todo2 = { version = "0.1.0", features = ["log"] }
#[macro_use]
extern crate todo2;
#[macro_use]
extern crate log;

use simple_logger::SimpleLogger;

fn main() {
    // Initialize the logger
    SimpleLogger::new().init().unwrap();

    todo!("Make a cool crate", by: 2024-02-02)
}

This will log an error like this when the deadline is met:

2024-02-02T17:27:07.013874956Z ERROR [logging_example] src/main.rs:9: Make a cool crate

consider that you can't enable the compile-error feature with the log feature. only one of them can be enabled at a time.

Using the compile-error feature

First, add the crate to your Cargo.toml and enable the compile-error feature:

cargo add todo2 --features compile-error
#[macro_use]
extern crate todo2;

fn main() {
   todo!("Remove this secret", by: 2024-02-23);
   let my_little_secret = "very secret";
}

this will emit a compile error like this, when u try to compile the code in release mode.

Time in the by condition

by default, the by condition takes a raw date and parse it with our custom parser, which expects the date in the YYYY-MM-DD format and YYYY-MM-DD at HH:MM or YYYY-MM-DD @ HH:MM format if you have the and-time feature enabled. and then it calculates the unix time stamp in UTC, and then compares it with the current time stamp.

this for the parsing part, noting interested here. just macros magic. the complexity comes when we want to calculate the unix time stamp from the parsed date. here the time zones and the daylight saving time and the leap seconds come to play. and I don't want to deal with this complexity 'cause I'm lazy and this is a "proc macro" not a normal crate witch means that it runs at compile time, and we all know that the rust compile times is so "fast" :) and I don't want to make it slower. so I implemented a simple algorithm to calculate the unix time stamp, which is not accurate, but it works. hmm, kinda.

Backends

and that's why we have the chrono-backend and the time-backend features, to use the chrono or the time crate to calculate the unix time stamp instead of the default implementation.

I encourage you to enable one of them if you don't have a problem with adding yet another dependence to your project dependencies tree, or if you already have one of them in your dependencies already. at least until we have a better implementation for the default backend.

the backend doesn't affect the parsing part, or the syntax, it only affects the calculation of the unix time stamp, witch is internal thing, so you don't have to worry about it from this perspective.

Maybe?

Here some ideas that I may implement in the future releases:

  • Implement the with-chrono feature, to enable the user to use the chrono::Utc or chrono::DateTime types to specify the deadline for the by condition instead of the raw date. example:
todo!("Make a cool crate", by: chrono::Utc.with_ymd_and_hms(2024, 02, 02, 9, 0, 0));
todo!("Make a cool crate", by: time::macros::datetime!(2024-02-02 09:00:00));
  • Make the if condition parser able to evaluate some conditions at compile time, so we can use the compile-error feature with the if condition. example:
   todo!("Remove this secret", if: !cfg!(debug_assertions));
   let my_little_secret = "i love you";

Contributing

I'm happy to accept any contributions, just consider reading the CONTRIBUTING.md guide first. to avoid waste waste our time on some unnecessary things.

the main keywords are: signed commits, conventional commits, no emojis, the PR shouldn't have more then tree commits most of the time

License

This project is licensed under the MIT license. Read more And you can use it under the Unlicense license if you want. Read more

Comments
  • fix(deps): update rust crate proc-macro2 to 1.0.68 - abandoned

    fix(deps): update rust crate proc-macro2 to 1.0.68 - abandoned

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | proc-macro2 | dependencies | patch | 1.0.67 -> 1.0.68 |


    Release Notes

    dtolnay/proc-macro2 (proc-macro2)

    v1.0.68

    Compare Source

    • Fix panic in Span::source_text() when source contains multibyte characters (#​408)

    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    size/XS 
    opened by renovate[bot] 2
  • chore(deps): bump proc-macro2 from 1.0.67 to 1.0.68

    chore(deps): bump proc-macro2 from 1.0.67 to 1.0.68

    Bumps proc-macro2 from 1.0.67 to 1.0.68.

    Release notes

    Sourced from proc-macro2's releases.

    1.0.68

    • Fix panic in Span::source_text() when source contains multibyte characters (#408)
    Commits
    • a3e94df Release 1.0.68
    • 299d8ff Merge pull request #409 from dtolnay/sourcetext
    • 7f5533d Account for multibyte chars in source_text() computation
    • 4fe2326 Add source_text() test with mulitbyte char
    • 07bb590 Remove ancient todo comments
    • 7921d32 Test docs.rs documentation build in CI
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    size/XS dependencies rust 
    opened by dependabot[bot] 0
  • fix(deps): update rust crate time to 0.3.29

    fix(deps): update rust crate time to 0.3.29

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | time (source) | dependencies | patch | 0.3.28 -> 0.3.29 |


    Release Notes

    time-rs/time (time)

    v0.3.29

    Compare Source

    Added
    • Niche value optimization for Date has been added. Both Date and Option<Date> are four bytes.

    • Unit conversions have been added. It is now possible to write Second::per(Day), which returns the number of seconds in one day. See the types in the [time::convert module][time::convert module] for more information.

    Changed
    • The diagnostic for --cfg unsound_local_offset has been removed.
    • #![feature(no_coverage)] was previously used internally for code coverage. It is no longer used, so it has been removed.
    • The default value for modifier::OffsetHour has been changed. This was unintentionally changed in v0.3.17 and went unnoticed until now. The sign is now only present if needed by default, as was the case previously. This does not affect any situation where format_description! or format_description::parse is used.
    Fixed
    • Adding or subtracting a std::time::Duration to/from an OffsetDateTime will not result in integer overflow internally. It will still panic if the result is out of range.

    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    size/XS 
    opened by renovate[bot] 0
  • fix(deps): update rust crate chrono to 0.4.31

    fix(deps): update rust crate chrono to 0.4.31

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | chrono | dependencies | patch | 0.4.30 -> 0.4.31 |


    Release Notes

    chronotope/chrono (chrono)

    v0.4.31: 0.4.31

    Compare Source

    Another maintenance release. It was not a planned effort to improve our support for UNIX timestamps, yet most PRs seem related to this.

    Deprecations
    • Deprecate timestamp_nanos in favor of the non-panicking timestamp_nanos_opt (#​1275)
    Additions
    Fixes
    • Format day of month in RFC 2822 without padding (#​1272)
    • Don't allow strange leap seconds which are not on a minute boundary initialization methods (#​1283) This makes many methods a little more strict:
      • NaiveTime::from_hms_milli
      • NaiveTime::from_hms_milli_opt
      • NaiveTime::from_hms_micro
      • NaiveTime::from_hms_micro_opt
      • NaiveTime::from_hms_nano
      • NaiveTime::from_hms_nano_opt
      • NaiveTime::from_num_seconds_from_midnight
      • NaiveTime::from_num_seconds_from_midnight_opt
      • NaiveDate::and_hms_milli
      • NaiveDate::and_hms_milli_opt
      • NaiveDate::and_hms_micro
      • NaiveDate::and_hms_micro_opt
      • NaiveDate::and_hms_nano
      • NaiveDate::and_hms_nano_opt
      • NaiveDateTime::from_timestamp
      • NaiveDateTime::from_timestamp_opt
      • TimeZone::timestamp
      • TimeZone::timestamp_opt
    • Fix underflow in NaiveDateTime::timestamp_nanos_opt (#​1294, thanks @​crepererum)
    Documentation
    • Add more documentation about the RFC 2822 obsolete date format (#​1267)
    Internal
    • Remove internal __doctest feature and doc_comment dependency (#​1276)
    • CI: Bump actions/checkout from 3 to 4 (#​1280)
    • Optimize NaiveDate::add_days for small values (#​1214)
    • Upgrade pure-rust-locales to 0.7.0 (#​1288, thanks @​jeremija wo did good improvements on pure-rust-locales)

    Thanks to all contributors on behalf of the chrono team, @​djc and @​pitdicker!


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    size/XS 
    opened by renovate[bot] 0
  • Configure Renovate

    Configure Renovate

    Mend Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • Cargo.toml (cargo)
    • .github/workflows/ci.yml (github-actions)

    Configuration Summary

    Based on the default config's presets, Renovate will:

    • Start dependency updates only once this onboarding PR is merged
    • Show all Merge Confidence badges for pull requests.
    • Enable Renovate Dependency Dashboard creation.
    • Use semantic commit type fix for dependencies and chore for all others if semantic commits are in use.
    • Ignore node_modules, bower_components, vendor and various test/tests directories.
    • Group known monorepo packages together.
    • Use curated list of recommended non-monorepo package groupings.
    • Apply crowd-sourced package replacement rules.
    • Apply crowd-sourced workarounds for known problems with packages.

    🔡 Would you like to change the way Renovate is upgrading your dependencies? Simply edit the renovate.json in this branch with your custom config and the list of Pull Requests in the "What to Expect" section below will be updated the next time Renovate runs.


    What to Expect

    With your current configuration, Renovate will create 1 Pull Request:

    fix(deps): update rust crate chrono to 0.4.31
    • Schedule: ["at any time"]
    • Branch name: renovate/chrono-0.x
    • Merge into: aurora
    • Upgrade chrono to 0.4.31

    ❓ Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by Mend Renovate. View repository job log here.

    size/XS 
    opened by renovate[bot] 0
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    This repository currently has no open or pending branches.

    Detected dependencies

    cargo
    Cargo.toml
    • chrono 0.4.31
    • time 0.3.29
    • quote 1.0.33
    • proc-macro2 1.0.68
    github-actions
    .github/workflows/ci.yml
    • actions/checkout v4
    • actions-rs/toolchain v1
    • actions-rs/cargo v1
    • actions/checkout v4
    • actions-rs/toolchain v1
    • Swatinem/rust-cache v2
    • codecov/codecov-action v3
    • actions/checkout v4
    • actions/checkout v4
    • actions-rs/toolchain v1
    • Swatinem/rust-cache v2
    • actions-rs/cargo v1
    • actions-rs/cargo v1
    • EmbarkStudios/cargo-deny-action v1
    • actions-rs/audit-check v1
    • lycheeverse/lychee-action v1

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    opened by renovate[bot] 0
Releases(0.1.3)
  • 0.1.3(Sep 27, 2023)

    What's Changed

    • Configure Renovate by @renovate in https://github.com/0x61nas/todo2/pull/1
    • fix(deps): update rust crate chrono to 0.4.31 by @renovate in https://github.com/0x61nas/todo2/pull/2
    • fix(deps): update rust crate time to 0.3.29 by @renovate in https://github.com/0x61nas/todo2/pull/4

    New Contributors

    • @renovate made their first contribution in https://github.com/0x61nas/todo2/pull/1

    Full Changelog: https://github.com/0x61nas/todo2/compare/0.1.2...0.1.3

    Source code(tar.gz)
    Source code(zip)
  • 0.1.2(Sep 22, 2023)

Owner
Anas
0E4F 7AB7 210F A285 6F1A AD7E 3844 2349 DD00 D8C6
Anas
HP++: A Hazard Pointers Extension for Better Applicability

HP++: A Hazard Pointers Extension for Better Applicability This is an implementation of HP++, a safe memory reclamation scheme proposed in Jaehwang Ju

KAIST Concurrency & Parallelism Laboratory 3 May 10, 2023
A Rust macro for writing nested loop expressions

loop_chain A Rust macro for writing nested loop expressions Usage | Examples | Docs Dependencies [dependencies] loop_chain = "0.1.1" Usage For express

Takayuki Maeda 5 Jul 30, 2021
Macro assembler for Rust

Macro Assembler This crate implement JSC/SpiderMonkey like macro assembler. Macro assembler purpose is to generate machine code for different platform

playX 6 Nov 26, 2022
A procedural macro for configuring constant values across crates

toml-cfg Rough ideas: Crates can declare variables that can be overridden Anything const, e.g. usize, strings, etc. (Only) The "root crate" can overri

James Munns 43 Dec 24, 2022
A Rust attribute macro that adds memoization to a function (rhymes with Mickey)

michie (sounds like Mickey) — an attribute macro that adds memoization to a function. Table of contents Features Non-features key_expr key_type store_

Mobus Operandi 16 Dec 20, 2022
Proc macro implementation of #[naked]

#[naked] Documentation This crate provide a proc macro version of the #[naked] attribute which can be used on stable Rust. Example // The SYSV64 calli

Amanieu d'Antras 10 Aug 13, 2022
Macro for fast implementing serialize methods in serde::Serializer trait

impl_serialize! This library provides a simple procedural macro for fast implementing serialize methods in serde::Serializer trait. [dependencies] imp

Eduard Baturin 2 Sep 6, 2022
hashmap macro for creating hashmap from provided key/value pairs

HashMap Macro Creates a HashMap from provided key/value pairs. Usage use std::collections::HashMap; use hashmap_macro::hashmap; let m: HashMap<&str,

null 6 Oct 2, 2022
Procedural macro to derive Serde serializer-deserializer for Prost

prost-serde-derive prost-serde-derive is a procedural macro to generate Serde serializers and deserializers for Prost-generated structs. Rationale Cur

Park Joon-Kyu 4 Dec 15, 2022
Library and proc macro to analyze memory usage of data structures in rust.

Allocative: memory profiler for Rust This crate implements a lightweight memory profiler which allows object traversal and memory size introspection.

Meta Experimental 19 Jan 6, 2023
Simple Rust derive-macro that simplifies integral enum creation

Integral enum A simple way to define integer-like enums. This macro implements bunch of traits that are usually implemented via looooong derive(..) at

null 3 Jan 6, 2023
proc-macro to help with using surrealdb's custom functions

SurrealDB Functions This is a proc-macro crate that given a path to a .surql file or a folder of .surql files, will parse DEFINE FUNCTION fn::s inside

Aly 5 Jul 30, 2023
A procedural macro to generate a new function implementation for your struct.

Impl New ?? A procedural macro to generate a new function implementation for your struct. ?? Add to your project Add this to your Cargo.toml: [depende

Mohammed Alotaibi 4 Sep 8, 2023
A turing-complete programming language using only zero-width unicode characters, inspired by brainfuck and whitespace.

Zero-Width A turing-complete programming language using only zero-width unicode characters, inspired by brainfuck and whitespace. Currently a (possibl

Gavin M 2 Jan 14, 2022
High concurrency, RealTime, In-memory storage inspired by erlang mnesia

DarkBird is a Document oriented, high concurrency in-memory Storage, also persist data to disk to avoid loss any data The darkbird provides the follow

DanyalMh 25 Dec 15, 2022
A ML-Inspired programming language that transpiles to Typescript

Hazure Programming language that compiles to Typescript! Note: Everything in this project can be changed at anytime! (I'm still finding out what work

azur 36 Dec 19, 2022
todo-or-die provides procedural macros that act as checked reminders.

todo-or-die provides procedural macros that act as checked reminders.

David Pedersen 552 Dec 24, 2022
A todo list app that indexes your app to find TODO:'s

forgot A todo list app that indexes your app to find TODO:'s Usage to list all your todos forgot list list all your todos ignoring search in ./target,

null 2 Oct 6, 2022
Sample and plot power consumption, average frequency and cpu die temperatures over time.

sense Sense is a small tool to gather data on cpu temperature, power usage and clock frequency and plot graphs during some load. Dependencies Sense is

Luuk van der Duim 6 Oct 31, 2022
A system clipboard command line tools which inspired by pbcopy & pbpaste but better to use.

rclip A command line tool which supports copy a file contents to the system clipboard or copy the contents of the system clipboard to a file. Install

yahaa 3 May 30, 2022