|
所在平台: Udemy |
课程主页: https://www.udemy.com/course/rust-programming-language-the-complete-reference/
课程评论:没有评论
**Coursera 课程总结:Rust 编程语言:完全参考指南** 本课程是关于 Rust 编程语言的全面介绍,Rust 是一种用于系统编程的强大语言,适用于操作系统、网络、文件系统、数据库、加密等领域。 **Rust 的主要特性:** * **并发与内存安全:** Rust 在编译时提供内存安全保证,并非常适合编写多线程应用程序。 * **类型安全:** 确保代码的健壮性。 * **变量与可变性:** 默认情况下,Rust 中的变量是不可变的。可以使用 `mut` 关键字来声明可变变量。Rust 还支持“遮蔽”(shadowing)的概念,允许使用相同的变量名重新声明变量。 * **数据类型:** Rust 不支持自动类型转换。可以使用下划线作为大数字的分隔符。 * **打印:** 使用 `println!()` 宏进行输出。宏比函数功能更强大。 * **字符串:** Rust 字符串分为字符串字面量(string literals)和字符串对象(string objects)。 * **控制流:** `match` 语句类似于 C/C++ 中的 `switch` 语句。 * **函数:** 函数可以通过值或引用传递参数。使用 `->` 指定返回类型。 * **所有权系统:** Rust 引入了所有权的概念,这是其内存安全的关键。`move` 操作类似于其他语言中的浅拷贝。 * **内存管理:** Rust 同时使用栈(stack)和堆(heap)内存。 * **Trait:** Rust 的 `trait` 类似于面向对象语言中的接口。存在 `Copy` trait。 * **引用与借用:** Rust 提供了引用和借用机制来管理内存。 * **垃圾回收与异常处理:** Rust 没有垃圾回收机制,也没有传统的异常处理(如 try-catch)。 * **切片(Slices):** 切片是指向内存块的指针,字符串切片即是字符串字面量。 * **结构体(Structs):** Rust 的结构体与 C/C++ 中的结构体类似。 * **枚举(Enums)与模块(Modules):** Rust 支持枚举和模块化编程。 * **集合(Collections):** Rust 提供了 `Vector`、`Hash Map` 和 `Hash Set` 等常用集合。 * **错误处理:** Rust 将错误分为可恢复错误和不可恢复错误(通过 `panic!` 宏)。 * **泛型:** 支持泛型类型和泛型结构体,提高代码的复用性。 本课程为学习 Rust 提供了坚实的基础,涵盖了语言的关键概念和特性。
General Introduction. Rust is for Systems programming. Systems programming is used Operating Systems, Networking, File systems, Databases , Cryptography and much more. Rust is very popular with Concurrency, memory safety at compile time, and multithreaded applications and type safety. Variables and mutability. By default variables are immutable in Rust. There is a concept called shadowing in Rust. We use println!() macro for printing. Macros are an extended version of functions. Data types. Automatic type casting is not allowed in Rust. Number separator for large numbers using underscores possible in Rust. The mut keyword is used for mutability. Rust strings are divided into string literals and string objects. Match statement is used in Rust like the switch case statement in C/C++. For returning values from functions we can use a single arrow -> like this to indicate a return type. Parameters are passed to functions by value as well as by Reference as in other languages. There is a concept called Rust Ownership. The move operation in Rust is similar to a shallow copy in other languages. We have the stack memory as well as the Heap memory. Rust trait is very much similar to the concept of interfaces in Object oriented programming languages. There is a concept called copy trait in Rust. Rust References and Borrowing. Observe Rust does not have the idea of Garbage collection. There is nothing like Exception handling also in Rust. Rust slices. A slice is a pointer to a block of memory. String slices are literals. Rust structure is similar to structures in other languages. Rust has Enums as well as Modules. Rust collections include Vector, Hash Map and Hash Set. Rust Error handling. Recoverable and Unrecoverable errors in Rust. Panic macro and Unrecoverable errors. Generic types, Generic structures.