File tree 4 files changed +50
-0
lines changed
4 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ /target
2
+ /Cargo.lock
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " encode_rs"
3
+ version = " 0.1.0"
4
+ edition = " 2021"
5
+
6
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
+
8
+ [lib ]
9
+ name = " encode_rs"
10
+ path = " src/lib.rs"
11
+
12
+ [[bin ]]
13
+ name = " encode"
14
+ path = " src/bin.rs"
15
+
16
+ [dependencies ]
17
+ bitvec = " 1"
18
+ byteorder = " 1.4.3"
Original file line number Diff line number Diff line change
1
+ use encode_rs:: print_bits;
2
+
3
+ fn main ( ) {
4
+ print_bits ( ) ;
5
+ }
Original file line number Diff line number Diff line change
1
+ use bitvec:: prelude:: * ;
2
+
3
+ pub fn print_bits ( ) {
4
+ let mut buffer = "hello" . as_bytes ( ) . to_owned ( ) ;
5
+ // Consume original buffer in u8 to a BitVec buffer
6
+ let bits = buffer. view_bits :: < Msb0 > ( ) ;
7
+ let ( head, rest) = bits. split_at ( 6 ) ;
8
+ println ! ( "{:?}" , bits) ;
9
+ println ! ( "{:?}" , head) ;
10
+ println ! ( "{:?}" , rest) ;
11
+ // for n in buffer.into_iter() {
12
+ // let mut bv: BitVec = n.into();
13
+ // bit_buff.append(&mut bv);
14
+ // }
15
+ }
16
+
17
+
18
+ #[ cfg( test) ]
19
+ mod tests {
20
+ #[ test]
21
+ fn it_works ( ) {
22
+ let result = 2 + 2 ;
23
+ assert_eq ! ( result, 4 ) ;
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments