Programming Rust, 2nd Edition

Programming Rust, 2nd Edition

作者:Leonora F.S. Tindall

出版社:O'Reilly Media, Inc.

出版年:2021-5-4

评分:9.7

ISBN:9781492052593

所属分类:行业好书

书刊介绍

内容简介

The Rust programming language offers the rare and valuable combination of statically verified memory safety and low-level control. Imagine C++ but without dangling pointers, null pointer dereferences, leaks, or buffer overruns. With this practical guide, systems programmers will understand Rust’s rules clearly and economically. You’ll learn how to express programs that Rust can prove are free of a broad class of common errors.

Rust brings the benefits of an expressive modern type system to systems programming. Authors Jim Blandy and Jason Orendorff demonstrate how Rust’s features put programmers in control over memory consumption and processor use, combining predictable performance with memory safety and trustworthy concurrency.

You’ll learn:

How to write fast, safe, concurrent programs in Rust

Rust’s rules for managing memory efficiently, including ownership, borrowing, moves, and lifetimes

How to design interfaces that fit well into the Rust ecosystem

Rust’s all-purpose Cargo tool for building, testing, and managing Rust packages

High-level features like traits, generics, closures, and iterators that make Rust productive and flexible

作者简介

Jim Blandy has been programming since 1981, and writing Free software since 1990. He has been the maintainer of GNU Emacs and GNU Guile, and a maintainer of GDB, the GNU Debugger. He is one of the original designers of the Subversion version control system. Jim now works on Firefox’s web developer tools for Mozilla.

精彩摘录

You'veheardthatRustletsyouwritesafe,fase,concurrentprograms.Thisisthechapterwhereweshowyouhowit'sdone.We'llcoverthreewaystouseRustthreads:1.Fork-joinparallelism2.Channels3.Sharedmuatblestate

——引自第458页


Apanicisnotacrash.It’snotundefinedbehavior.It’smorelikeaRuntimeExceptioninJavaorastd::logic_errorinC++.Thebehavioriswell-defined;itjustshouldn’tbehappening.Panicissafe.Itdoesn’tviolateanyofRust’ssafetyrules;evenifyoumanagetopanicinthemiddleofastandardlibrarymethod,itwillneverleaveadanglingpointerorahalf-initializedvalueinmemory.TheideaisthatRustcatchestheinvalidarrayaccess,orwhateveritis,beforeanythingbadhappens.Itwouldbeunsafetoproceed,soRustunwindsthestack.Buttherestoftheprocesscancontinuerunning.Panicisperthread.Onethreadcanbepanickingwhileotherthreadsaregoingonabouttheirnormalbusiness.InChapter19,we’llshowhowaparentthreadcanfindoutwhenachildthrea...

——引自第1页

相关推荐

微信二维码