Skip to content

SpanishPear/macrokata

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MacroKata

Welcome to MacroKata, a set of exercises which you can use to learn how to write macros in rust. When completing each task, there are three goals:

  • Get your code to compile without warnings or errors.
  • Get your code to "work correctly" (i.e. produce the same output)
  • Importantly, generate the same code as what the sample solution does.

You should complete the kata in order, as they increase in difficulty, and depend on previous kata.

Getting Started

Clone this repository:

$ git clone https://www.github.com/tfpk/macrokata/

You will also need to install the rust "nightly" toolchain, so that we can show expanded macros.

$ rustup toolchain install nightly

And install cargo expand.

$ cargo install cargo-expand

Build the main binary provided with this repo:

$ cargo build

You can find the first kata (my_first_macro) inside tasks/01_my_first_macro. Read the README.md file, and get started by editing the main.rs file.

To compare your expanded code to the "goal"; use the test subcommand.

$ cargo run -- test 01_my_first_macro

To run your own code, use:

$ cargo run --bin 01_my_first_macro

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 99.3%
  • Shell 0.7%