Skip to Content
Effective Rust ―Rustコードを改善し、エコシステムを最大限に活用するための35項目
book

Effective Rust ―Rustコードを改善し、エコシステムを最大限に活用するための35項目

by David Drysdale, 中田 秀基
November 2024
Intermediate to advanced
304 pages
4h 24m
Japanese
O'Reilly Japan, Inc.
Content preview from Effective Rust ―Rustコードを改善し、エコシステムを最大限に活用するための35項目

3章さまざまなコンセプト

本書の1章と2章ではRustの型とトレイトについて説明した。これで、Rustコードを書く上で必要になるコンセプトを説明するのに必要なボキャブラリの準備ができたことになる。本章では、さまざまなコンセプトについて説明していく。

借用チェッカと生存期間チェックは、Rustをユニークなものにしている中心的なコンセプトだ。これらは同時に、Rust初心者がつまずく障害でもあるので、本章の最初の2項目でこれらを解説する。

本章のこれら以外の項目は、これら2つよりは理解しやすいはずだが、やはり他の言語で書く場合とは少し異なる。本章の最初の2項目以外の内容は以下の通りだ。

  • Rustのunsafeモードに関する説明とそれを避ける方法に関するアドバイス([項目16]
  • マルチスレッドコードをRustで書くことに関する良いニュースと悪いニュース([項目17]
  • 実行時アボートを避けるべきというアドバイス([項目18]
  • Rustのリフレクションに関する情報([項目19]
  • 性能最適化とメンテナンス性のバランスに関するアドバイス([項目20]

これらのコンセプトから導かれる結論に従ってコードを書くようにしよう。RustでC/C++の挙動(の一部)を再現することは「可能」だが、それではRustを使う意味がない。

項目14:生存期間を理解しよう

この項目では、Rustの生存期間を解説する。理論的にはともかく実用面から見ると、生存期間はCやC++などの従来のコンパイル言語にもあった概念を、より精密に定式化したものだ。生存期間は[項目15]で説明する借用チェッカの入力として用いられる。これら2つが合わさって、Rustのメモリ安全性保証の中核をなす。

スタック入門

生存期間は、本質的に ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Effective Rust

Effective Rust

David Drysdale
Hands-on Rust

Hands-on Rust

Herbert Wolverson
Command-Line Rust

Command-Line Rust

Ken Youens-Clark

Publisher Resources

ISBN: 9784814400942Publisher Website