In addition to the countless code examples, you’ll find three chapters dedicated to building complete projects: a number-guessing game, a Rust implementation of a command line tool, and a multithreaded server. The best ways to test, handle errors, refactor, and take advantage of expressive pattern matching.How to use Cargo, Rust’s built-in package manager, to build, document your code, and manage dependencies.Smart pointers and multithreading, and how ownership interacts with them to enable fearless concurrency.Ownership and borrowing, lifetimes, generics, traits, and trait objects to communicate your program’s constraints to the compiler.You’ll begin with basics like creating functions, choosing data types, and binding variables, then move on to more advanced concepts, such as: Klabnik and Nichols, alumni of the Rust Core Team, share their knowledge to help you get the most out of Rust’s features so that you can create robust and scalable programs. Rust provides control of low-level details along with high-level ergonomics, allowing you to improve productivity and eliminate the hassle traditionally associated with low-level languages. The Rust Programming Language, 2nd Edition is the official guide to Rust 2021: an open source systems programming language that will help you write faster, more reliable software. Rust has been repeatedly voted "Most Loved Language" on the StackOverflow Developer Survey. The Rust Programming Language "covers everything you could want to know about the language."-Stack Overflow Thoroughly updated to Rust’s latest version, this edition is considered the language’s official documentation. | - immutable borrow later used hereįor more information about this error, try `rustc -explain E0502`.With over 50,000 copies sold, The Rust Programming Language is the quintessential guide to programming in Rust. fn greet_user(name: Option) !", nickname) Here’s an example of a function to greet someone whether or not we know their name if we had forgotten the None case in the match or tried to use name as if it was an always-present String value, the compiler would complain. This prevents occurrences of the dreaded TypeError: Cannot read property 'foo' of null runtime error (or language equivalent), instead promoting it to a compile time error you can resolve before a user ever sees it. Like Haskell and some other modern programming languages, Rust encodes this possibility using an optional type, and the compiler requires you to handle the None case. This means any value may be what it says or nothing, effectively creating a second possible type for every type. Many statically-typed languages have a large asterisk next to them: they allow for the concept of NULL. This isn’t to say that all static type systems are equivalent. Statically-typed languages allow for compiler-checked constraints on the data and its behavior, alleviating cognitive overhead and misunderstandings. You only need to look at the rise of languages like TypeScript or features like Python’s type hints as people have become frustrated with the current state of dynamic typing in today’s larger codebases. The arguments between programmers who prefer dynamic versus static type systems are likely to endure for decades more, but it’s hard to argue about the benefits of static types. It’s not all roses in Rust-land, so I talk about the downsides, too. I’ll show a sample of what Rust offers to users of other programming languages and what the current ecosystem looks like. The short answer is that Rust solves pain points present in many other languages, providing a solid step forward with a limited number of downsides. However, the roughly 97% of survey respondents who haven’t used Rust may wonder, “What’s the deal with Rust?” Rust has been Stack Overflow’s most loved language for four years in a row, indicating that many of those who have had the opportunity to use Rust have fallen in love with it.
0 Comments
Leave a Reply. |