Comprehensive Rust(繁体中文) 202406
that don't depend on libc, allocator or even the presence of an operating system. • alloc 包括需要全域堆積配置器的型別,例如 Vec、Box 和 Arc。 • 嵌入式 Rust 應用程式通常只使用 core,偶爾會使用 alloc。 16.2 說明文件測試 Rust 說明文件的主題涵蓋甚廣,包括: • help functional- style programming. • Result 是實作錯誤處理的標準型別,我們將在第 3 天的課程中介紹。 16.5 String String 是標準堆積配置的可成長 UTF-8 字串緩衝區: fn main() { let mut s1 = String::new(); s1.push_str("Hello"); println!("s1: len Display, so anything that can be formatted can also be converted to a string. 16.6 Vec Vec 是可調整大小的標準堆積配置緩衝區: fn main() { let mut v1 = Vec::new(); v1.push(42); println!("v1: len = {}, capacity = {}", v10 码力 | 356 页 | 1.41 MB | 1 年前3
共 1 条
- 1