Commit 418a078
authored
Rollup merge of rust-lang#124103 - dtolnay:metadatadebug, r=Mark-Simulacrum
Improve std::fs::Metadata Debug representation
- Remove duplication of `mode` between `file_type` and `permissions`, which both involve operating on the same mode_t integer
- Add `is_symlink`
- Add `len` in bytes
- Remove Ok wrapping around `modified`, `accessed`, `created`, which eliminates 6 useless lines
<table>
<tr><th>Before</th><th>After</th></tr>
<tr><td>
```console
Metadata {
file_type: FileType(
FileType {
mode: 0o100600 (-rw-------),
},
),
is_dir: false,
is_file: true,
permissions: Permissions(
FilePermissions {
mode: 0o100600 (-rw-------),
},
),
modified: Ok(
SystemTime {
tv_sec: 1713402981,
tv_nsec: 682983531,
},
),
accessed: Ok(
SystemTime {
tv_sec: 1713402983,
tv_nsec: 206999623,
},
),
created: Ok(
SystemTime {
tv_sec: 1713402981,
tv_nsec: 682983531,
},
),
..
}
```
</td><td>
```console
Metadata {
file_type: FileType {
is_file: true,
is_dir: false,
is_symlink: false,
..
},
permissions: Permissions(
FilePermissions {
mode: 0o100600 (-rw-------),
},
),
len: 2096,
modified: SystemTime {
tv_sec: 1713402981,
tv_nsec: 682983531,
},
accessed: SystemTime {
tv_sec: 1713402983,
tv_nsec: 206999623,
},
created: SystemTime {
tv_sec: 1713402981,
tv_nsec: 682983531,
},
..
}
```
</td></tr></table>
Generated by:
```rust
fn main() {
println!("{:#?}", std::fs::metadata("Cargo.toml").unwrap());
}
```1 file changed
+26
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| |||
1410 | 1410 | | |
1411 | 1411 | | |
1412 | 1412 | | |
1413 | | - | |
1414 | | - | |
1415 | | - | |
1416 | | - | |
1417 | | - | |
1418 | | - | |
1419 | | - | |
1420 | | - | |
1421 | | - | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
1422 | 1427 | | |
1423 | 1428 | | |
1424 | 1429 | | |
| |||
1684 | 1689 | | |
1685 | 1690 | | |
1686 | 1691 | | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
1687 | 1703 | | |
1688 | 1704 | | |
1689 | 1705 | | |
| |||
0 commit comments