Comprehensive Rust(繁体中文) 202406then they wouldn’t be the same type as they would if they were all defined in an enum. • Rust 會以最少的空間來儲存判別值。 – 如有需要,Rust 會儲存最小所需大小的整數 – 如果允許的變體值未涵蓋所有位元模式,Rust 會使用無效的位元模式來編碼判別值 (即「區 位最佳化」)。舉例來說,Option<&u8> Bar::C as u32); } 如果沒有 repr,判別值型別會需要 2 個位元組,因為 10001 適合 2 個位元組。 探索更多內容 Rust 支援多種最佳化做法,可用於縮減列舉占用的空間。 • 空值指標最佳化:針對部分型別,Rust 保證 size_of::() 等於size_of:: 0 码力 | 356 页 | 1.41 MB | 1 年前3
共 1 条
- 1













