Croc-look is a tool to make testing and debuging proc macros easier

Overview

croc-look

croc-look is a tool to make testing and debuging proc macros easier by these two features

  1. Printing the implementation specific generated code to the console
  2. Giving a real time live view of the output of the macro on rust code

croc-look allows you to narrow down your search and also provide real time view of the generated code.

Blog post

Installation

croc-look requires a nightly toolchain installed, it does not need to be the default toolchain

rustup install nightly

Then

cargo install croc-look

Flags

  1. --trait-impl or -t: Defines the trait you want to see the expansion off, this is gonna be the trait your derive macro is implementing or it could be any other trait you want to see the expansion off. For example
#[derive(Clone, Debug, MyTrait)]
struct {
  ...
}

So the value for this flag can be either Clone, Debug or whatever trait your MyTrait derive macro is implementing

  1. --impl-for or -i: This helps you narrow down your search for a trait impl for the flag mentioned above. If you have multiple structs deriving your trait then you can do croc-look --trait-impl Clone -i and get the impl for the struct you want.

  2. --structure or -s: If you want to expand a particlar struct. This is useful when a macro is manupilating the struct itself, like adding fields, etc.

  3. --path or -p: (requies cargo expand to be installed) Use cargo expand internally to narrow down code to modules. eg croc-look -p cmd -t Clone -i Context (This finds the impl Clone for Context in cmd module)

  4. --function or -f: For expanding a function.

  5. --binary or -b: To expand a cargo --bin BINARY, if not specified then --lib is used

  6. --watch or -w: This starts watching the directory/file you want to watch, this also opens up an interactive TUI which has support for live reloading changes as you do them in your proc-macro project.

How is this different from cargo expand?

cargo expand doesn't allow you to view a whole trait impl to check generics or watch particular code blocks. The motive of croc-look is to narroy arry down your search to a simple single body and reduce cluter.

You can use the --path flag to use cargo expand to narrow down searches module level

License

Licensed under MIT license.
You might also like...
A zero-dependency crate for writing repetitive code easier and faster.

akin A zero-dependency crate for writing repetitive code easier and faster. Check Syntax for information about how to use it. Why? Example Syntax NONE

png_defringe_rs is a port of Immorpher's PNG Defringe program written in Rust to achieve easier installation and faster performance.

png_defringe_rs png_defringe_rs is a port of Immorpher's PNG Defringe program written in Rust to achieve easier installation and faster performance. U

ChatGPT powered Rust proc macro that generates code at compile-time.

gpt-macro ChatGPT powered Rust proc macro that generates code at compile-time. Implemented Macros auto_impl!{} #[auto_test(...)] Usage Get ChatGPT API

A dead simple functional testing tool for command line applications

Pharaoh : build that test pyramid! What it is Pharaoh is a dead simple, no permission needed, functional test runner for command line applications, wr

Command line tool to make conventional commit messages

Commit This project is a copy of cz-cli with some minor changes. I made this project for my own use, because I don't want to mess with the original cz

A workflow tool for quickly running / testing something you are working on

runfast What is it? This is a program intended to be run in a project directory to set up a project run command, and remember it so we dont have to ty

A gui tool written in Dioxus to make it easy to release a workspace of crates to crates.io
A gui tool written in Dioxus to make it easy to release a workspace of crates to crates.io

Easy-Release: a visual tool for releasing workspaces of libraries A work-in-progress GUI for releasing a large workspace of crates manually, but easil

Server load testing CLI tool 🏋️

🔥 Rhea A Server Load Testing Tool Rhea is a powerful and easy-to-use command-line tool written in Rust for load testing servers. It allows you to sim

Api testing tool made with rust to use for api developement (Kind of Tui)
Api testing tool made with rust to use for api developement (Kind of Tui)

Api testing tool made with rust to use for api developement (Kind of Tui) This Rust project provides a simple yet powerful tool for making HTTP reques

Write simple proc-macros inline with other source code.

script-macro An experimental way to write simple proc-macros inline with other source code. Did you ever end up getting frustrated at the boilerplate

Markus Unterwaditzer 17 Jun 10, 2023
Set of tools that make it easier for the operator to manage a TAPLE network.

⚠️ TAPLE is in early development and should not be used in production ⚠️ TAPLE Tools TAPLE (pronounced T+ ?? ['tapəl]) stands for Tracking (Autonomous

Open Canarias 5 Jan 25, 2023
Js-macros - Quickly prototype Rust procedural macros using JavaScript or TypeScript!

js-macros Quickly prototype Rust procedural macros using JavaScript or TypeScript! Have you ever thought "this would be a great use case for a procedu

null 15 Jun 17, 2022
A tool to compare how Typst documents would look using different fonts or font variants.

typst-font-compare A tool to compare how Typst documents would look using different fonts or font variants. Installation cargo install --path . Usage

null 3 Feb 15, 2024
A WIP property-based testing library in Rust, built with generalized targeted-property testing in mind.

Crabcheck A WIP property-based testing library in Rust, built with generalized targeted-property testing in mind. What is property-based testing? TODO

Alperen Keleş 9 Mar 27, 2024
A tool that makes writing WebAssembly Text files easier.

Silly WAT Linker SWL is a tool that makes writing WebAssembly Text files easier. It is future-proof and simple because it doesn’t actually understand

Surma 27 Feb 17, 2023
Rust library for regular expressions using "fancy" features like look-around and backreferences

fancy-regex A Rust library for compiling and matching regular expressions. It uses a hybrid regex implementation designed to support a relatively rich

fancy-regex 302 Jan 3, 2023
Look Ma: My computer is talking!

chatgpt-at-home A simple text generator based on n-grams and Markov chains: $ cargo run --release > :train sources/shakespeare.txt > ACT IV ACT IV.

Patryk Wychowaniec 5 Mar 26, 2023
👀Little program I made in 🦀Rust that reminds me every 20 minutes to look away from my computer 🖥screen.

?? eye break Little program I made in ?? Rust that reminds me every 20 minutes to look away from my computer ?? screen. I stay way too long on the com

Goldy 3 Apr 9, 2023
Toki pona word look-up in the CLI

seme toki pona word look-up in the CLI note the UCSUR are just a square for me because my font doesn't support them, but if yours does you should see

víctor 4 Feb 25, 2024