bitmatch:一个Rust板条箱,可让您匹配,绑定和打包整数的各个位

时间:2024-03-28 05:45:05
【文件属性】:

文件名称:bitmatch:一个Rust板条箱,可让您匹配,绑定和打包整数的各个位

文件大小:23KB

文件格式:ZIP

更新时间:2024-03-28 05:45:05

rust encoding binary decoding rust-library

位匹配 位匹配板条箱提供了用于打包和解包整数作为位序列的工具。 支持#![no_std] 。 例子 将#[bitmatch]与let一起使用,可将您使用的每个字母的位解压缩到单独的单字符变量中。 使用bitpack!()将那些单字符变量中的位重新打包为单个整数。 use bitmatch :: bitmatch; #[bitmatch] fn interleave (n: u8 ) -> u8 { #[bitmatch] let "xxxx_yyyy" = n; bitpack! ( "xyxy_xyxy" ) } fn main () { assert_eq! ( interleave ( 0xF0 ), 0xAA ); } 您也可以在match上使用#[bitmatch] ,它将确保文字部分匹配并绑定变量部分。 use bitmatch ::


【文件预览】:
bitmatch-develop
----Cargo.toml(686B)
----test.py(368B)
----ensure-no-std()
--------.cargo()
--------Cargo.toml(261B)
--------src()
----src()
--------test.rs(771B)
--------lib.rs(17KB)
----.dev-suite()
--------hooked()
--------ticket()
--------repo-config.toml(82B)
----README.md(1KB)
----tests()
--------test.rs(2KB)
----.gitignore(19B)

网友评论