Write Powerful Rust Macros
暫譯: 撰寫強大的 Rust 巨集

Van Overmeire, Sam

  • 出版商: Manning
  • 出版日期: 2024-07-16
  • 售價: $2,160
  • 貴賓價: 9.5$2,052
  • 語言: 英文
  • 頁數: 320
  • 裝訂: Quality Paper - also called trade paper
  • ISBN: 1633437493
  • ISBN-13: 9781633437494
  • 相關分類: Rust 語言
  • 立即出貨

相關主題

商品描述

An example-driven, step-by-step guide to success with Rust macros.

In Write Powerful Rust Macros you'll learn how to use these amazing metaprogramming tools to push Rust to its full potential. This hands-on guide takes you from the absolute basics to advanced macro techniques, exploring Rust macros through interesting and engaging examples.

Inside Write Powerful Rust Macros you'll discover:

  • Writing declarative macros
  • Procedural macros
  • Reading and debugging macro code
  • Improving the type system with newtypes and zero-sized types
  • How common Rust libraries use macros

Write Powerful Rust Macros teaches you how to write, test, debug, and publish macros for Rust. It's perfect for Rust practitioners who want to master this powerful development technique. Build your knowledge chapter-by-chapter. You'll start with declarative macros before diving into the real power: procedural macros that can generate code, augment data structures, and even create domain-specific languages.

Purchase of the print book includes a free eBook in PDF and ePub formats from Manning Publications.

About the technology

Macros are one of Rust's most important and powerful tools. Although notoriously challenging, this metaprogramming technique has a big payoff. Using macros to generate new Rust code at compile-time can save you hours of tedious coding with negligible runtime performance impact. This book shows you exactly how to master this Rust superpower.

About the book

Write Powerful Rust Macros opens up the world of macros to intermediate Rust programmers. You'll start with declarative macros to get the basics under your belt. Then, you'll advance to procedural macros as you automatically generate a builder, learn to create your own domain-specific languages, and more. As you go, you'll develop practical skills like testing macros, integrating macros with crates, and even sharing your macros with other developers.

What's inside

  • How Rust libraries use macros
  • Reading and debugging macro code
  • newtypes and the type state pattern

About the reader

For intermediate Rust programmers.

About the author

Sam Van Overmeire is an experienced Rust developer and the author of multiple books, scientific articles and blog posts.

The technical editor on this book was Andrew Lilley Brinker.

Table of contents

1 Going meta
2 Declarative macros
3 A "Hello, World" procedural macro
4 Making fields public with attribute macros
5 Hiding information and creating mini-DSLs with function-like macros
6 Testing a builder macro
7 From panic to result: Error handling
8 Builder with attributes
9 Writing an infrastructure DSL
10 Macros and the outside world

商品描述(中文翻譯)

一個以範例為驅動的逐步指南,助你成功掌握 Rust 宏。

撰寫強大的 Rust 宏 中,你將學會如何使用這些驚人的元編程工具,充分發揮 Rust 的潛力。這本實用指南將帶你從最基本的概念到進階的宏技術,通過有趣且引人入勝的範例探索 Rust 宏。

撰寫強大的 Rust 宏 中,你將發現:

  • 撰寫宣告式宏
  • 程序式宏
  • 閱讀和除錯宏代碼
  • 使用新類型和零大小類型改善類型系統
  • 常見的 Rust 函式庫如何使用宏

撰寫強大的 Rust 宏 教你如何撰寫、測試、除錯和發佈 Rust 的宏。這本書非常適合希望掌握這一強大開發技術的 Rust 實踐者。逐章建立你的知識。你將從宣告式宏開始,然後深入真正的力量:可以生成代碼、增強數據結構,甚至創建特定領域語言的程序式宏。

購買印刷版書籍可獲得 Manning Publications 提供的免費 PDF 和 ePub 格式電子書。

關於技術

宏是 Rust 最重要和最強大的工具之一。儘管這種元編程技術以挑戰性著稱,但其回報卻相當可觀。使用宏在編譯時生成新的 Rust 代碼,可以節省你數小時的繁瑣編碼,且對運行時性能影響微乎其微。本書將向你展示如何掌握這一 Rust 超能力。

關於本書

撰寫強大的 Rust 宏 為中級 Rust 程式設計師打開了宏的世界。你將從宣告式宏開始,掌握基本概念。然後,你將進階到程序式宏,自動生成建構器,學習創建自己的特定領域語言,等等。在這個過程中,你將發展出實用技能,如測試宏、將宏與 crate 整合,甚至與其他開發者分享你的宏。

內容概覽

  • Rust 函式庫如何使用宏
  • 閱讀和除錯宏代碼
  • 新類型和類型狀態模式

關於讀者

針對中級 Rust 程式設計師。

關於作者

Sam Van Overmeire 是一位經驗豐富的 Rust 開發者,並且是多本書籍、科學文章和部落格文章的作者。

本書的技術編輯是 Andrew Lilley Brinker

目錄

1 進入元編程
2 宣告式宏
3 一個「Hello, World」程序式宏
4 使用屬性宏使欄位公開
5 隱藏資訊並使用類似函數的宏創建迷你 DSL
6 測試建構器宏
7 從 panic 到 result:錯誤處理
8 帶有屬性的建構器
9 撰寫基礎設施 DSL
10 宏與外部世界

作者簡介

Sam Van Overmeire is a software developer with a background in history and archaeology. He is the author of multiple books, scientific articles and blog posts.

作者簡介(中文翻譯)

Sam Van Overmeire 是一位具有歷史和考古背景的軟體開發人員。他是多本書籍、科學文章和部落格文章的作者。