Những Khái Niệm Lập Trình Cơ Bản - The Rust Programming Language

  1. The Rust Programming Language
  2. Foreword
  3. Introduction
  4. Bắt đầu với Rust
    1. Cài đặt
    2. Hello, World!
    3. Hello, Cargo!
  5. Lập trình game đoán số
  6. Những khái niệm lập trình cơ bản
    1. Biến và tính khả biến
    2. Kiểu dữ liệu
    3. Hàm
    4. Comments
    5. Luồng điều khiển
  7. Hiểu về Ownership
    1. Ownership là gì?
    2. Tham chiếu và vay mượn
    3. The Slice Type
  8. Using Structs to Structure Related Data
    1. Defining and Instantiating Structs
    2. An Example Program Using Structs
    3. Method Syntax
  9. Enums and Pattern Matching
    1. Defining an Enum
    2. The match Control Flow Operator
    3. Concise Control Flow with if let
  10. Managing Growing Projects with Packages, Crates, and Modules
    1. Packages and Crates
    2. Defining Modules to Control Scope and Privacy
    3. Paths for Referring to an Item in the Module Tree
    4. Bringing Paths Into Scope with the use Keyword
    5. Separating Modules into Different Files
  11. Common Collections
    1. Storing Lists of Values with Vectors
    2. Storing UTF-8 Encoded Text with Strings
    3. Storing Keys with Associated Values in Hash Maps
  12. Error Handling
    1. Unrecoverable Errors with panic!
    2. Recoverable Errors with Result
    3. To panic! or Not to panic!
  13. Generic Types, Traits, and Lifetimes
    1. Generic Data Types
    2. Traits: Defining Shared Behavior
    3. Validating References with Lifetimes
  14. Writing Automated Tests
    1. How to Write Tests
    2. Controlling How Tests Are Run
    3. Test Organization
  15. An I/O Project: Building a Command Line Program
    1. Accepting Command Line Arguments
    2. Reading a File
    3. Refactoring to Improve Modularity and Error Handling
    4. Developing the Library’s Functionality with Test Driven Development
    5. Working with Environment Variables
    6. Writing Error Messages to Standard Error Instead of Standard Output
  16. Functional Language Features: Iterators and Closures
    1. Closures: Anonymous Functions that Can Capture Their Environment
    2. Processing a Series of Items with Iterators
    3. Improving Our I/O Project
    4. Comparing Performance: Loops vs. Iterators
  17. More about Cargo and Crates.io
    1. Customizing Builds with Release Profiles
    2. Publishing a Crate to Crates.io
    3. Cargo Workspaces
    4. Installing Binaries from Crates.io with cargo install
    5. Extending Cargo with Custom Commands
  18. Smart Pointers
    1. Using Box to Point to Data on the Heap
    2. Treating Smart Pointers Like Regular References with the Deref Trait
    3. Running Code on Cleanup with the Drop Trait
    4. Rc, the Reference Counted Smart Pointer
    5. RefCell and the Interior Mutability Pattern
    6. Reference Cycles Can Leak Memory
  19. Fearless Concurrency
    1. Using Threads to Run Code Simultaneously
    2. Using Message Passing to Transfer Data Between Threads
    3. Shared-State Concurrency
    4. Extensible Concurrency with the Sync and Send Traits
  20. Object Oriented Programming Features of Rust
    1. Characteristics of Object-Oriented Languages
    2. Using Trait Objects That Allow for Values of Different Types
    3. Implementing an Object-Oriented Design Pattern
  21. Patterns and Matching
    1. All the Places Patterns Can Be Used
    2. Refutability: Whether a Pattern Might Fail to Match
    3. Pattern Syntax
  22. Advanced Features
    1. Unsafe Rust
    2. Advanced Traits
    3. Advanced Types
    4. Advanced Functions and Closures
    5. Macros
  23. Final Project: Building a Multithreaded Web Server
    1. Building a Single-Threaded Web Server
    2. Turning Our Single-Threaded Server into a Multithreaded Server
    3. Graceful Shutdown and Cleanup
  24. Appendix
    1. A - Keywords
    2. B - Operators and Symbols
    3. C - Derivable Traits
    4. D - Useful Development Tools
    5. E - Editions
    6. F - Translations of the Book
    7. G - How Rust is Made and “Nightly Rust”
The Rust Programming Language Những khái niệm lập trình cơ bản

Chương này đề cập đến những khái niệm xuất hiện trong hầu hết mọi ngôn ngữ lập trình và cách chúng hoạt động trong Rust. Nhiều ngôn ngữ lập trình có nhiều điểm cốt lõi chung. Không có khái niệm nào trong chương này là độc nhất ở Rust, nhưng chúng ta sẽ thảo luận về chúng trong ngữ cảnh của Rust và giải thích những quy ước xung quanh việc sử dụng những khái niệm này.

Đặc biệt, bạn sẽ học về biến, những kiểu cơ bản, hàm, comment và luồng điều khiển. Những điều này sẽ nằm trong mọi chương trình Rust, và học chúng sớm sẽ cho bạn một nền móng vững chắc để bắt đầu.

Từ khóa

Ngôn ngữ Rust có một bộ các từ khóa (keyword) được dành riêng và chỉ được sử dụng bới ngôn ngữ, giống như trong những ngôn ngữ khác. Hãy luôn nhớ rằng bạn không thể dùng những từ này cho tên biến hay tên hàm. Hầu hết các từ khóa có ý nghĩa đặc biệt, bạn sẽ dùng chúng để làm nhiều loại tác vụ trong chương trình Rust của bạn; một vài từ khóa hiện tại chưa có tính năng liên quan nhưng sẽ được sử dụng trong tương lai. Bạn có thể xem danh sách từ khóa ở Phụ lục A.

Từ khóa » Học Rust