Registry / utility / bytemuck

bytemuck

JSON →
library1.25.0rscratesunverified

A crate for mucking around with piles of bytes.

# Cargo.toml [dependencies] bytemuck = "1.25.0"
INSTALL
IMPORT
SIG · BYTEMUCK
B
bytemuck
utilityrustv1.25.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cast
use bytemuck::cast;

Reinterpret a u32 as a byte array using bytemuck.

use bytemuck::cast; fn main() { let value: u32 = 0x12345678; let bytes: [u8; 4] = cast(value); println!("{:?}", bytes); }
Debug
Known issues
gotchaUndefined behavior if types have padding or invalid bit patterns
fix
Ensure types implement Pod (plain old data) or Zeroable, and avoid casting between types with different sizes
affects: >=1.0.0
Upgrade
Version history
1.25.0latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
bytemuck — cargo add bytemuck · libregistry