文檔列表見:Rust 移動端跨平臺複雜圖形渲染項目開發系列總結(目錄)post
C++以64位系統爲編譯目標時數據類型與Rust對應關係以下所示。spa
C++ | Rust |
---|---|
void | std::os::raw::c_void |
char | i8 |
short | i16 |
int | i32 |
long | i64 |
unsigned char | u8 |
unsigned short | u16 |
unsigned int | u32 |
unsigned long | u64 |
size_t | usize |
float | f32 |
double | f64 |
bool | bool |
char* | &str |
std::string | String |
其實,char對i8或u8都行,知足8 bit存儲空間便可,映射成u8更方便用String和Vec操做。code
for c in my_str.chars() {
// do something with `c`
}
for (i, c) in my_str.chars().enumerate() {
// do something with character `c` and index `i`
}
複製代碼
LeetCode練習題:leetcode
參考:開發