Skip to content

Commit

Permalink
Update 3.常见方法使用.md
Browse files Browse the repository at this point in the history
  • Loading branch information
fyhhub authored Apr 12, 2024
1 parent 6eea212 commit c0fe541
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/rust-learn/笔记/3.常见方法使用.md
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
```

0 comments on commit c0fe541

Please sign in to comment.