Apache License 2.0

项目介绍

tfpk/macrokata 是一个托管在 GitHub 上的开源项目,主要使用 Rust 编写,采用 Apache License 2.0 许可证,目前获得 1.2k 个 Star、88 次 Fork。

仓库全名
tfpk/macrokata
开源许可证
Apache License 2.0
Star 数
1.2k
Fork 数
88
未关闭 Issue
6

README 摘要

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…

完整内容见 GitHub 原始 README 或本页 。

常见问题

macrokata 用什么语言开发?

主要使用 Rust 编写,采用 Apache License 2.0 许可证,目前有 1.2k 个 Star。

macrokata 可以免费商用吗?

仓库采用 Apache License 2.0 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 macrokata 的源码?

可以直接克隆仓库:git clone https://github.com/tfpk/macrokata.git,默认分支为 main;安装与运行步骤见仓库 README。

macrokata 最近还在维护吗?

仓库最近一次更新为 2024年7月13日,当前有 6 个未关闭 Issue;Star 数为 1.2k,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

Learn Macros In Rust

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
1412
价值分
762
活跃状态
活跃

语言占比

CSS
Handlebars
JavaScript
Rust
Shell

README

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.

This set of exercises is written for people who have already spent some time programming in Rust. Before completing this, work through a Rust tutorial and build some small programs yourself.

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

Next, install cargo-expand:

$ cargo install cargo-expand

Build the main binary provided with this repo:

$ cargo build --bin macrokata

You can find the first kata (my_first_macro) inside exercises/01_my_first_macro. Read the first chapter of the book 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

You can run your own code as follows:

$ cargo run --bin 01_my_first_macro

How To Learn About Procedural Macros

I was originally planning to expand macrokata into discussing procedural macros as well. As I was researching that, I found dtolnay’s superlative Proc Macro Workshop. Jon Gjengset’s video on proc-macros is also a phenomenal resource (despite its length).

I’ve put my attempt to write something like that on hold because I think the above is better in every way. Do file an issue if there’s something that we could do here to complement that workshop though.

评论

暂无评论