#coffee #blazing-fast #cargo-build #relax

macro build coffee_break

Take a break while your code compiles

2 stable releases

2.1.1 Apr 9, 2024
1.0.0 Mar 22, 2024

#211 in Build Utils

Download history 142/week @ 2024-03-20 17/week @ 2024-03-27 95/week @ 2024-04-03 73/week @ 2024-04-10

327 downloads per month

JSON license

9KB
63 lines

Coffee break

crates.io badge docs.rs badge

Coffee break

Coffee break is a 🔥 blazing 🚀 fast 🦀 Rust 🥵 library, by Rust developers for Rust developers. It is:

  • Developer-friendly: Lets you take a break while compiling your code.
  • Eco-friendly: The compiler is just taking a nap. We're not computing the Ackermann function just to slack off.
  • Language server-unfriendly: rust-analyzer has insomnia now.

Overview

XKCD compiling

A classic XKCD webcomic

45% of respondents to the 2023 Rust survey were concerned with Rust's compile times, and they're right: they're too dang fast!

In the before times when working on old C++ projects, we used to get 10 to 40 minutes of free time after we hit compile to do whatever we wanted. Developers' computers had no more than 2 to 4 CPU cores, and Makefiles were often not configured to run in parallel at all.

Nowadays, the devious Rust compiler developers are trying to make the compiler even faster, and they're slowly succeeding.

Here comes Coffee break, a friendly developer tool to make this problem go away.

Example

Before you run cargo build, reward yourself with a coffee break:

use coffee_break::coffee_break;

fn work_stuff() {
    let maybe = |(true|false)||(false|true)||(true|false)|true;
    let absolutely = maybe(true)(true)(true);

    // Take a break and hit compile
    coffee_break!(5 minutes);
}

You just got 5 minutes to stretch your legs, get a coffee, or make Friday afternoon a bit nicer.

You can take a break for up to 251 minutes, or up to 1319 seconds. These limits are arbitrary, and will not be changed for any reason, unless the author changes their mind.

This crate requires correct grammar:

fn work_stuff() {
    coffee_break!(1 second); // OK
    coffee_break!(5 minutes); // OK
    // coffee_break!(59 second); // Error
    // coffee_break!(1 minutes); // Error
}

You can still run cargo check and cargo clippy without having to wait.

Notes

The author doesn't drink coffee, but still enjoys taking a break.

Contributing

Before contributing to this project, consider taking a coffee break first.

PRs are welcome. The first paragraph of any PR message must be a haiku describing the changes.

Please follow the community guidelines.

License

This project is licensed under a license modeled on the JSON license. Evil doesn't deserve a break.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Coffee break by you, shall be licensed with this repository's license, without any additional terms or conditions.

Dependencies

~325–780KB
~19K SLoC