Take a break while compiling.

Overview

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.

You might also like...
Docker images for compiling static Rust binaries using musl-libc and musl-gcc, with static versions of useful C libraries. Supports openssl and diesel crates.

rust-musl-builder: Docker container for easily building static Rust binaries Source on GitHub Changelog UPDATED: Major updates in this release which m

Docker images for compiling static Rust binaries using musl-cross

rust-musl-cross Docker images for compiling static Rust binaries using musl-cross-make, inspired by rust-musl-builder Prebuilt images Currently we hav

Everything you need to know about cross compiling Rust programs!

rust-cross Everything you need to know about cross compiling Rust programs! If you want to set up your Rust toolchain as a cross compiler, you have co

A collection of compilers based around compiling a high level language to a Brainfuck dialect.
A collection of compilers based around compiling a high level language to a Brainfuck dialect.

tf A collection of compilers based around compiling a high level language to a Brainfuck dialect. Built at, and for, the VolHacks V hackathon during O

Easy-to-use wrapper for WebRTC DataChannels peer-to-peer connections written in Rust and compiling to WASM.

Easy-to-use wrapper for WebRTC DataChannels peer-to-peer connections written in Rust and compiling to WASM.

MidenIR for compiling to Miden Assembly from higher-level languages

Miden IR This repository provides a compiler for the Miden VM, specifically for Miden Assembly. It does this by lowering from a higher-level intermedi

Rust library for compiling and running other programs.

Exers đŸ’» Exers is a rust library for compiling and running code in different languages and runtimes. Usage example fn main() { // Imports...

A blazingly fast compiling & optimization tool for CosmWasm smart contracts.
A blazingly fast compiling & optimization tool for CosmWasm smart contracts.

cw-optimizoor A blazingly fast alternative to CosmWasm/rust-optimizer for compiling & optimizing CW smart contracts. It's primarily meant to speed up

Utilities for working with native solc and compiling projects.

foundry-compilers Utilities for working with native solc and compiling projects. To also compile contracts during cargo build (so that ethers abigen!

ripgrep recursively searches directories for a regex pattern while respecting your gitignore
ripgrep recursively searches directories for a regex pattern while respecting your gitignore

ripgrep (rg) ripgrep is a line-oriented search tool that recursively searches the current directory for a regex pattern. By default, ripgrep will resp

A programming environment that aims to help people learn how to program in JavaScript, while giving them a tour on how old computers and their limitations used to be.
A programming environment that aims to help people learn how to program in JavaScript, while giving them a tour on how old computers and their limitations used to be.

This repository is for the new under renovation rewrite of the LIKO-12 project. The legacy version with the original stars and contributions is still

Midnote is a terminal application that reads a MIDI file and displays you its notes bar-by-bar, while playing it.

MIDNOTE Midnote is a terminal application that reads a MIDI file and displays you its notes bar-by-bar, while playing it. Goals As a blind musician my

Collects accurate files while running in parallel through directories. (Simple, Fast, Powerful)

collectfiles Collects accurate files while running in parallel through directories. (Simple, Fast, Powerful) | Docs | Latest Note | [dependencies] col

Auritia is a DAW coded in Rust and Vue in hopes of having cross platform compatability, while also providing enough features for anyone to use professionally
Auritia is a DAW coded in Rust and Vue in hopes of having cross platform compatability, while also providing enough features for anyone to use professionally

Steps Install WebView if you're not on Windows 11 Install Node deps npm i To run the dev server do npm run tauri dev Compiling Linux You will need to

ripgrep recursively searches directories for a regex pattern while respecting your gitignore
ripgrep recursively searches directories for a regex pattern while respecting your gitignore

ripgrep (rg) ripgrep is a line-oriented search tool that recursively searches the current directory for a regex pattern. By default, ripgrep will resp

A collection of algorithms that can do join between two parties while preserving the privacy of keys on which the join happens

Private-ID Private-ID is a collection of algorithms to match records between two parties, while preserving the privacy of these records. We present tw

handle some lichess.org/tournament load with rust, while learning rust

lila-http Take some of the HTTP load away from lila. WIP! Arena tournaments Clients connected to a tournament page request new data about the tourname

Canary - Distributed systems library for making communications through the network easier, while keeping minimalism and flexibility.
Canary - Distributed systems library for making communications through the network easier, while keeping minimalism and flexibility.

Canary Canary is a distributed systems and communications framework, focusing on minimalism, ease of use and performance. Development of Canary utiliz

Comments
  • Remove `quote` dependency

    Remove `quote` dependency

    quote's only usage is returning a unit () statement. This behavior can be accomplished by calling TokenStream::new, which returns an empty token stream.

    This does change the generated output, but it still accomplishes the same result.

    // stretch_your_legs.rs
    
    // Before
    fn main() {
        ();
    }
    
    // After
    fn main() {
    
    }
    

    Unfortunately it only removes quote as an immediate dependency. syn still dependends on quote, even when I reduced the enabled features. I'm pretty sure this is a bug (on this line), but there is nothing that can be done in this PR.

    opened by BD103 3
  • Taking breaks for more than 251 minutes by calling 'coffee_break!' multiple times

    Taking breaks for more than 251 minutes by calling 'coffee_break!' multiple times

    Despite there being some limits on break time, we can take a break for more than 251 minutes by calling coffee_break! multiple times.

    Here is an example:

    fn work_stuff() {
        // I can take breaks for 250 minutes × 100, close to 416 hours (seems like I cannot go home today)
        for n in 1..100 {
            coffee_break!(250  minutes);
        }
    }
    

    I think we should save coffee-breaking logs as a file, in order to disallow taking breaks for multiple times.

    opened by ActiveTK 1
  • Add features `ra-friendly` and `check-friendly` to make it friendlier

    Add features `ra-friendly` and `check-friendly` to make it friendlier

    I love to take breaks, but not each time I ask rust-analyzer to complete something or when I run cargo check/clippy to find errors, so I added two optional features to make it friendlier to them.

    • ra-friendly for rust-analyzer
    • check-friendly for cargo check/clippy

    [EDIT] I took two coffee breaks during this PR :coffee:

    opened by v3rmine 0
Releases(2.1.1)
  • 2.1.1(Apr 9, 2024)

    This release contains the following improvements by these contributors:

    • BD103: Remove the quote dependency, making this crate faster to compile. Ironic. This is also technically a breaking change since the macro now emits nothing rather than an empty tuple.
    • joxcat: Make the library rust-analyzer friendly and friendly for cargo check. There are now two default features ra-friendly and check-friendly that add checks that don't activate the coffee break when we run in the context of rust-analyzer or when we aren't building respectively. This makes the crate not obliterate rust-analyzer when you add a coffee break and hit save, which is particurarly nice. With this change, you can realistically leave a coffee_break! in and continue working until you're ready to build and take a break.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Mar 22, 2024)

Owner
Radek VĂ­t
Senior Software Developer for CCleaner at Gen Digital
Radek VĂ­t
A simple CLI I made while practicing rust to easily make QR codes with just one command, all in your terminal.

Welcome to rust-qrcode-cli ?? A CLI I made while practicing rust to easily make QR codes with just one command, all in your terminal. Install git clon

Dhravya Shah 2 Mar 2, 2022
Firefox used to have this feature a while back (from Firefox 11 to 46) and it is so good, that I feel it needs revival.

3D WebPage Inspector By: Seanpm2001, Et; Al. Top README.md Read this article in a different language Sorted by: A-Z Sorting options unavailable ( af A

Sean P. Myrick V19.1.7.2 3 Nov 10, 2022
🍅 A command-line tool to get and set values in toml files while preserving comments and formatting

tomato Get, set, and delete values in TOML files while preserving comments and formatting. That's it. That's the feature set. I wrote tomato to satisf

C J Silverio 15 Dec 23, 2022
zkPoEX enables white hat hackers to report live vulnerabilities in smart contracts while maintaining the confidentiality of the exploit

zkPoEX enables white hat hackers to report live vulnerabilities in smart contracts while maintaining the confidentiality of the exploit, facilitating efficient communication and collaboration between hackers and project owners for a more secure DeFi ecosystem.

zkoranges 135 Apr 16, 2023
A lightweight async Web crawler in Rust, optimized for concurrent scraping while respecting `robots.txt` rules.

?? crawly A lightweight and efficient web crawler in Rust, optimized for concurrent scraping while respecting robots.txt rules. ?? Features Concurren

CrystalSoft 5 Aug 29, 2023
BudouX-rs is a rust port of BudouX (machine learning powered line break organizer tool).

BudouX-rs BudouX-rs is a rust port of BudouX (machine learning powered line break organizer tool). Note: This project contains the deliverables of the

null 5 Jan 20, 2022
🔼 Futuristic take on hexdump, made in Rust.

hex (hx) Futuristic take on hexdump. hx accepts a file path as input and outputs a hexadecimal colorized view to stdout. $ hx tests/files/alphanumeric

Julian Sitkevich 387 Dec 27, 2022
Take your first step in writing a compiler. Implemented in Rust.

first-step-rust Take your first step in writing a compiler, using Rust. Building from Source Make sure the Rust toolchain is installed on your compute

PKU Compiler Course 13 Aug 28, 2022
Take user input in Rust.

Take user input in Rust.

Kutay 0 Jan 25, 2022
Mk48.io is an online multiplayer naval combat game, in which you take command of a ship and sail your way to victory

Mk48.io Game Mk48.io is an online multiplayer naval combat game, in which you take command of a ship and sail your way to victory. Watch out for torpe

Softbear Studios 160 Jan 2, 2023