-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,26 @@ | ||
# 常见方法使用 | ||
# 常见方法使用 | ||
|
||
## size_of 获取指定类型的大小 | ||
|
||
```rust | ||
use std::mem::size_of; | ||
|
||
size_of::<Option<T>>() | ||
size_of::<u8>() | ||
// ... | ||
``` | ||
|
||
常见类型的大小: | ||
``` | ||
Type T Option<T> Result<T, io::Error> | ||
---------------------------------------------------------------- | ||
u8 1 2 24 | ||
f64 8 16 24 | ||
&u8 8 8 24 | ||
Box<u8> 8 8 24 | ||
&[u8] 16 16 24 | ||
String 24 24 32 | ||
Vec<u8> 24 24 32 | ||
HashMap<String, String> 48 48 56 | ||
E 56 56 64 | ||
``` |