diff options
Diffstat (limited to 'src/tools/clippy/src/docs/transmute_num_to_bytes.txt')
-rw-r--r-- | src/tools/clippy/src/docs/transmute_num_to_bytes.txt | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/transmute_num_to_bytes.txt b/src/tools/clippy/src/docs/transmute_num_to_bytes.txt new file mode 100644 index 000000000..a2c39a1b9 --- /dev/null +++ b/src/tools/clippy/src/docs/transmute_num_to_bytes.txt @@ -0,0 +1,16 @@ +### What it does +Checks for transmutes from a number to an array of `u8` + +### Why this is bad? +Transmutes are dangerous and error-prone, whereas `to_ne_bytes` +is intuitive and safe. + +### Example +``` +unsafe { + let x: [u8; 8] = std::mem::transmute(1i64); +} + +// should be +let x: [u8; 8] = 0i64.to_ne_bytes(); +```
\ No newline at end of file |