| 1 | // Copyright (c) 2015 Robert Clipsham <[email protected]> |
| 2 | // Copyright (c) 2021 Pierre Chifflier <[email protected]> |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 5 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 6 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 7 | // option. This file may not be copied, modified, or distributed |
| 8 | // except according to those terms. |
| 9 | |
| 10 | //! Utility functions for bit manipulation operations |
| 11 | |
| 12 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/; |
| 13 | |
| 14 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 15 | pub enum Endiannessrust-analyzer cargo pnet_macros 0.35.0 util/Endianness# { |
| 16 | Bigrust-analyzer cargo pnet_macros 0.35.0 util/Endianness#Big#, |
| 17 | Littlerust-analyzer cargo pnet_macros 0.35.0 util/Endianness#Little#, |
| 18 | Hostrust-analyzer cargo pnet_macros 0.35.0 util/Endianness#Host#, |
| 19 | } |
| 20 | |
| 21 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 22 | pub struct GetOperationrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation# { |
| 23 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: u8, |
| 24 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: u8, |
| 25 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: u8, |
| 26 | } |
| 27 | |
| 28 | impl fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for GetOperationrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation# { |
| 29 | fn fmtrust-analyzer cargo pnet_macros 0.35.0 util/impl#[GetOperation][Display]fmt().(&self, fmt: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 30 | let should_mask = self.maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0xFF; |
| 31 | let shift = (self.shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr. as i16) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().(self.shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl. as i16); |
| 32 | |
| 33 | let mask_str = if should_mask { |
| 34 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("({{}} & 0x{})", radix16_u8rust-analyzer cargo pnet_macros 0.35.0 util/radix16_u8().(self.maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.)) |
| 35 | } else { |
| 36 | "{}".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() |
| 37 | }; |
| 38 | |
| 39 | if shift rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 { |
| 40 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(fmt, "{}", mask_str) |
| 41 | } else if shift rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().0 { |
| 42 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(fmt, "{} << {}", mask_str, shift.absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]abs().()) |
| 43 | } else { |
| 44 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(fmt, "{} >> {}", mask_str, shift.absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]abs().()) |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 50 | fn test_display_get_operationrust-analyzer cargo pnet_macros 0.35.0 util/test_display_get_operation().() { |
| 51 | type Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# = GetOperationrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#; |
| 52 | |
| 53 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 54 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 55 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b00001111, |
| 56 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 2, |
| 57 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 58 | } |
| 59 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 60 | "({} & 0xf) << 2" |
| 61 | ); |
| 62 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 63 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 64 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b00001111, |
| 65 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 2, |
| 66 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 2, |
| 67 | } |
| 68 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 69 | "({} & 0xf)" |
| 70 | ); |
| 71 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 72 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 73 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b00001111, |
| 74 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 75 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 2, |
| 76 | } |
| 77 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 78 | "({} & 0xf) >> 2" |
| 79 | ); |
| 80 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 81 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 82 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111111, |
| 83 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 84 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 2, |
| 85 | } |
| 86 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 87 | "{} >> 2" |
| 88 | ); |
| 89 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 90 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 91 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111111, |
| 92 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 3, |
| 93 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 1, |
| 94 | } |
| 95 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 96 | "{} << 2" |
| 97 | ); |
| 98 | } |
| 99 | |
| 100 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 101 | pub struct SetOperationrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation# { |
| 102 | /// Bits to save from old byte |
| 103 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: u8, |
| 104 | /// Bits to mask out of value we're setting |
| 105 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: u64, |
| 106 | /// Number of places to left shift the value we're setting |
| 107 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: u8, |
| 108 | /// Number of places to right shift the value we're setting |
| 109 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: u8, |
| 110 | } |
| 111 | |
| 112 | macro_rules! radix_fnrust-analyzer cargo pnet_macros 0.35.0 util/radix_fn! { |
| 113 | ($name:ident, $ty:ty) => { |
| 114 | fn $name(mut val: $ty) -> String { |
| 115 | let mut ret = String::new(); |
| 116 | let vals = "0123456789abcdef".as_bytes(); |
| 117 | while val > 0 { |
| 118 | let remainder = val % 16; |
| 119 | val /= 16; |
| 120 | ret = format!("{}{}", vals[remainder as usize] as char, ret); |
| 121 | } |
| 122 | |
| 123 | ret |
| 124 | } |
| 125 | |
| 126 | mod $name { |
| 127 | #[test] |
| 128 | fn test() { |
| 129 | assert_eq!(super::$name(0xab), "ab".to_owned()); |
| 130 | assert_eq!(super::$name(0x1c), "1c".to_owned()); |
| 131 | } |
| 132 | } |
| 133 | }; |
| 134 | } |
| 135 | |
| 136 | radix_fnrust-analyzer cargo pnet_macros 0.35.0 util/radix_fn!!(radix16_u8rust-analyzer cargo pnet_macros 0.35.0 util/radix16_u8()., u8); |
| 137 | radix_fnrust-analyzer cargo pnet_macros 0.35.0 util/radix_fn!!(radix16_u64rust-analyzer cargo pnet_macros 0.35.0 util/radix16_u64()., u64); |
| 138 | |
| 139 | impl fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for SetOperationrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation# { |
| 140 | fn fmtrust-analyzer cargo pnet_macros 0.35.0 util/impl#[SetOperation][Display]fmt().(&self, fmt: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 141 | let should_mask = self.value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().0xFF; |
| 142 | let should_save = self.save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0x00; |
| 143 | let shift = (self.shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr. as i16) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().(self.shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl. as i16); |
| 144 | |
| 145 | let save_str = if should_save { |
| 146 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("({{packet}} & 0x{})", radix16_u8rust-analyzer cargo pnet_macros 0.35.0 util/radix16_u8().(self.save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.)) |
| 147 | } else { |
| 148 | "".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() |
| 149 | }; |
| 150 | |
| 151 | let mask_str = if should_mask { |
| 152 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("({{val}} & 0x{})", radix16_u64rust-analyzer cargo pnet_macros 0.35.0 util/radix16_u64().(self.value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.)) |
| 153 | } else { |
| 154 | "{val}".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() |
| 155 | }; |
| 156 | |
| 157 | let shift_str = if shift rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 { |
| 158 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", mask_str) |
| 159 | } else if shift rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().0 { |
| 160 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{} << {}", mask_str, shift.absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]abs().()) |
| 161 | } else { |
| 162 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{} >> {}", mask_str, shift.absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]abs().()) |
| 163 | }; |
| 164 | |
| 165 | if should_save { |
| 166 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!( |
| 167 | fmt, |
| 168 | "{{packet}} = ({} | ({}) as u8) as u8", |
| 169 | save_str, shift_str |
| 170 | ) |
| 171 | } else { |
| 172 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(fmt, "{{packet}} = ({}) as u8", shift_str) |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 178 | fn test_display_set_operationrust-analyzer cargo pnet_macros 0.35.0 util/test_display_set_operation().() { |
| 179 | type Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# = SetOperationrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#; |
| 180 | |
| 181 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 182 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 183 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00000011, |
| 184 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00001111, |
| 185 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 2, |
| 186 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 187 | } |
| 188 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 189 | "{packet} = (({packet} & 0x3) | (({val} & 0xf) << 2) as u8) as u8" |
| 190 | ); |
| 191 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 192 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 193 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b11000000, |
| 194 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00001111, |
| 195 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 2, |
| 196 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 2, |
| 197 | } |
| 198 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 199 | "{packet} = (({packet} & 0xc0) | (({val} & 0xf)) as u8) as u8" |
| 200 | ); |
| 201 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 202 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 203 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00011100, |
| 204 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00001111, |
| 205 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 0, |
| 206 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 2, |
| 207 | } |
| 208 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 209 | "{packet} = (({packet} & 0x1c) | (({val} & 0xf) >> 2) as u8) as u8" |
| 210 | ); |
| 211 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 212 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 213 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00000000, |
| 214 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b11111111, |
| 215 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 0, |
| 216 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 2, |
| 217 | } |
| 218 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 219 | "{packet} = ({val} >> 2) as u8" |
| 220 | ); |
| 221 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 222 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 223 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00000011, |
| 224 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b11111111, |
| 225 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 3, |
| 226 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 1, |
| 227 | } |
| 228 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 229 | "{packet} = (({packet} & 0x3) | ({val} << 2) as u8) as u8" |
| 230 | ); |
| 231 | } |
| 232 | |
| 233 | /// Gets a mask to get bits_remaining bits from offset bits into a byte |
| 234 | /// If bits_remaining is > 8, it will be truncated as necessary |
| 235 | fn get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(offset: usize, bits_remaining: usize) -> (usize, u8) { |
| 236 | fn bits_remaining_in_byterust-analyzer cargo pnet_macros 0.35.0 util/bits_remaining_in_byte().(offset: usize, bits_remaining: usize) -> usize { |
| 237 | fn round_downrust-analyzer cargo pnet_macros 0.35.0 util/round_down().(max_val: usize, val: usize) -> usize { |
| 238 | if val rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().max_val { |
| 239 | max_val |
| 240 | } else { |
| 241 | val |
| 242 | } |
| 243 | } |
| 244 | if (bits_remaining rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().8) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().1 { |
| 245 | 8 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().offset |
| 246 | } else { |
| 247 | round_downrust-analyzer cargo pnet_macros 0.35.0 util/round_down().(8 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().offset, bits_remaining) |
| 248 | } |
| 249 | } |
| 250 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(offset <= 7); |
| 251 | let mut num_bits_to_mask = bits_remaining_in_byterust-analyzer cargo pnet_macros 0.35.0 util/bits_remaining_in_byte().(offset, bits_remaining); |
| 252 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(num_bits_to_mask <= 8 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). offset); |
| 253 | let mut mask = 0; |
| 254 | while num_bits_to_mask rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 { |
| 255 | mask = mask rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor().(0x80 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shr<usize>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shr<usize>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shr<usize>`]shr().(offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().num_bits_to_mask rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1)); |
| 256 | num_bits_to_mask rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1; |
| 257 | } |
| 258 | |
| 259 | (bits_remaining_in_byterust-analyzer cargo pnet_macros 0.35.0 util/bits_remaining_in_byte().(offset, bits_remaining), mask) |
| 260 | } |
| 261 | |
| 262 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 263 | fn test_get_maskrust-analyzer cargo pnet_macros 0.35.0 util/test_get_mask().() { |
| 264 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(0, 1), (1, 0b10000000)); |
| 265 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(0, 2), (2, 0b11000000)); |
| 266 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(0, 3), (3, 0b11100000)); |
| 267 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(0, 4), (4, 0b11110000)); |
| 268 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(0, 5), (5, 0b11111000)); |
| 269 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(0, 6), (6, 0b11111100)); |
| 270 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(0, 7), (7, 0b11111110)); |
| 271 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(0, 8), (8, 0b11111111)); |
| 272 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(0, 9), (8, 0b11111111)); |
| 273 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(0, 100), (8, 0b11111111)); |
| 274 | |
| 275 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(1, 1), (1, 0b01000000)); |
| 276 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(1, 2), (2, 0b01100000)); |
| 277 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(1, 3), (3, 0b01110000)); |
| 278 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(1, 4), (4, 0b01111000)); |
| 279 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(1, 5), (5, 0b01111100)); |
| 280 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(1, 6), (6, 0b01111110)); |
| 281 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(1, 7), (7, 0b01111111)); |
| 282 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(1, 8), (7, 0b01111111)); |
| 283 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(1, 9), (7, 0b01111111)); |
| 284 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(1, 100), (7, 0b01111111)); |
| 285 | |
| 286 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(5, 1), (1, 0b00000100)); |
| 287 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(5, 2), (2, 0b00000110)); |
| 288 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(5, 3), (3, 0b00000111)); |
| 289 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(5, 4), (3, 0b00000111)); |
| 290 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(5, 5), (3, 0b00000111)); |
| 291 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(5, 6), (3, 0b00000111)); |
| 292 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(5, 7), (3, 0b00000111)); |
| 293 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(5, 8), (3, 0b00000111)); |
| 294 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(5, 100), (3, 0b00000111)); |
| 295 | } |
| 296 | |
| 297 | fn get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(offset: usize, size: usize, byte_number: usize, num_bytes: usize) -> u8 { |
| 298 | if num_bytes rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 || byte_number rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().num_bytes { |
| 299 | 0 |
| 300 | } else { |
| 301 | let base_shift = 8 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().((num_bytes rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().8) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().size); |
| 302 | let bytes_to_shift = num_bytes rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().byte_number rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().2; |
| 303 | |
| 304 | let ret = base_shift rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().(8 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().bytes_to_shift); |
| 305 | |
| 306 | // (ret % 8) as u8 |
| 307 | ret as u8 |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 312 | fn test_get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/test_get_shiftl().() { |
| 313 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(0, 8, 0, 1), 0); |
| 314 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(0, 9, 0, 2), 1); |
| 315 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(0, 9, 1, 2), 0); |
| 316 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(0, 10, 0, 2), 2); |
| 317 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(0, 10, 1, 2), 0); |
| 318 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(0, 11, 0, 2), 3); |
| 319 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(0, 11, 1, 2), 0); |
| 320 | |
| 321 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(1, 7, 0, 1), 0); |
| 322 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(1, 8, 0, 2), 1); |
| 323 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(1, 9, 0, 2), 2); |
| 324 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(1, 9, 1, 2), 0); |
| 325 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(1, 10, 0, 2), 3); |
| 326 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(1, 10, 1, 2), 0); |
| 327 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(1, 11, 0, 2), 4); |
| 328 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(1, 11, 1, 2), 0); |
| 329 | |
| 330 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(0, 35, 0, 5), 27); |
| 331 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(0, 35, 1, 5), 19); |
| 332 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(0, 35, 2, 5), 11); |
| 333 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(0, 35, 3, 5), 3); |
| 334 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(0, 35, 4, 5), 0); |
| 335 | } |
| 336 | |
| 337 | fn get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(offset: usize, size: usize, byte_number: usize, num_bytes: usize) -> u8 { |
| 338 | if byte_number rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().num_bytes { |
| 339 | ((num_bytes rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().8) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().size) as u8 |
| 340 | } else { |
| 341 | 0 |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 346 | fn test_get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/test_get_shiftr().() { |
| 347 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 1, 0, 1), 7); |
| 348 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 2, 0, 1), 6); |
| 349 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 3, 0, 1), 5); |
| 350 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 4, 0, 1), 4); |
| 351 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 5, 0, 1), 3); |
| 352 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 6, 0, 1), 2); |
| 353 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 7, 0, 1), 1); |
| 354 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 8, 0, 1), 0); |
| 355 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 9, 0, 2), 0); |
| 356 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 9, 1, 2), 7); |
| 357 | |
| 358 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(1, 7, 0, 1), 0); |
| 359 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(1, 8, 0, 2), 0); |
| 360 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(1, 8, 1, 2), 7); |
| 361 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(1, 9, 0, 2), 0); |
| 362 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(1, 9, 1, 2), 6); |
| 363 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(1, 10, 0, 2), 0); |
| 364 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(1, 10, 1, 2), 5); |
| 365 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(1, 11, 0, 2), 0); |
| 366 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(1, 11, 1, 2), 4); |
| 367 | |
| 368 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 35, 0, 5), 0); |
| 369 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 35, 1, 5), 0); |
| 370 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 35, 2, 5), 0); |
| 371 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 35, 3, 5), 0); |
| 372 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(0, 35, 4, 5), 5); |
| 373 | } |
| 374 | |
| 375 | /// Given an offset (number of bits into a chunk of memory), retrieve a list of operations to get |
| 376 | /// size bits. |
| 377 | /// |
| 378 | /// Assumes big endian, and that each byte will be masked, then cast to the next power of two |
| 379 | /// greater than or equal to size bits before shifting. offset should be in the range [0, 7] |
| 380 | pub fn operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(offset: usize, size: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<GetOperationrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#>> { |
| 381 | if offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().7 || size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 || size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().64 { |
| 382 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 383 | } |
| 384 | |
| 385 | |
| 386 | let start = offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().8; |
| 387 | let end = (offset+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().size-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().8; |
| 388 | let num_bytes = (end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().start) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1; |
| 389 | |
| 390 | let mut current_offset = offset; |
| 391 | let mut num_bits_remaining = size; |
| 392 | let mut ops = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(num_bytes); |
| 393 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#num_bytes { |
| 394 | let (consumed, mask) = get_maskrust-analyzer cargo pnet_macros 0.35.0 util/get_mask().(current_offset, num_bits_remaining); |
| 395 | ops.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(GetOperationrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation# { |
| 396 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: mask, |
| 397 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: get_shiftlrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftl().(offset, size, i, num_bytes), |
| 398 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: get_shiftrrust-analyzer cargo pnet_macros 0.35.0 util/get_shiftr().(offset, size, i, num_bytes), |
| 399 | }); |
| 400 | current_offset = 0; |
| 401 | if num_bits_remaining rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().consumed { |
| 402 | num_bits_remaining rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().consumed; |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ops) |
| 407 | } |
| 408 | |
| 409 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 410 | fn operations_testrust-analyzer cargo pnet_macros 0.35.0 util/operations_test().() { |
| 411 | type Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# = GetOperationrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#; |
| 412 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 413 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(0, 1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 414 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 415 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b10000000, |
| 416 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 417 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 7, |
| 418 | }] |
| 419 | ); |
| 420 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 421 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(0, 2).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 422 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 423 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11000000, |
| 424 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 425 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 6, |
| 426 | }] |
| 427 | ); |
| 428 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 429 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(0, 3).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 430 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 431 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11100000, |
| 432 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 433 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 5, |
| 434 | }] |
| 435 | ); |
| 436 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 437 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(0, 4).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 438 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 439 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11110000, |
| 440 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 441 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 4, |
| 442 | }] |
| 443 | ); |
| 444 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 445 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(0, 5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 446 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 447 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111000, |
| 448 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 449 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 3, |
| 450 | }] |
| 451 | ); |
| 452 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 453 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(0, 6).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 454 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 455 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111100, |
| 456 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 457 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 2, |
| 458 | }] |
| 459 | ); |
| 460 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 461 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(0, 7).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 462 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 463 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111110, |
| 464 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 465 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 1, |
| 466 | }] |
| 467 | ); |
| 468 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 469 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(0, 8).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 470 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 471 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111111, |
| 472 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 473 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 474 | }] |
| 475 | ); |
| 476 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 477 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(0, 9).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 478 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 479 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 480 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111111, |
| 481 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 1, |
| 482 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 483 | }, |
| 484 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 485 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b10000000, |
| 486 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 487 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 7, |
| 488 | } |
| 489 | ] |
| 490 | ); |
| 491 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 492 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(0, 10).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 493 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 494 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 495 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111111, |
| 496 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 2, |
| 497 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 498 | }, |
| 499 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 500 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11000000, |
| 501 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 502 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 6, |
| 503 | } |
| 504 | ] |
| 505 | ); |
| 506 | |
| 507 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 508 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(1, 1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 509 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 510 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01000000, |
| 511 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 512 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 6, |
| 513 | }] |
| 514 | ); |
| 515 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 516 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(1, 2).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 517 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 518 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01100000, |
| 519 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 520 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 5, |
| 521 | }] |
| 522 | ); |
| 523 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 524 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(1, 3).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 525 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 526 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01110000, |
| 527 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 528 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 4, |
| 529 | }] |
| 530 | ); |
| 531 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 532 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(1, 4).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 533 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 534 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01111000, |
| 535 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 536 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 3, |
| 537 | }] |
| 538 | ); |
| 539 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 540 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(1, 5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 541 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 542 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01111100, |
| 543 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 544 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 2, |
| 545 | }] |
| 546 | ); |
| 547 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 548 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(1, 6).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 549 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 550 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01111110, |
| 551 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 552 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 1, |
| 553 | }] |
| 554 | ); |
| 555 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 556 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(1, 7).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 557 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 558 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01111111, |
| 559 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 560 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 561 | }] |
| 562 | ); |
| 563 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 564 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(1, 8).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 565 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 566 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 567 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01111111, |
| 568 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 1, |
| 569 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 570 | }, |
| 571 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 572 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b10000000, |
| 573 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 574 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 7, |
| 575 | } |
| 576 | ] |
| 577 | ); |
| 578 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 579 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(1, 9).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 580 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 581 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 582 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01111111, |
| 583 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 2, |
| 584 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 585 | }, |
| 586 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 587 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11000000, |
| 588 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 589 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 6, |
| 590 | } |
| 591 | ] |
| 592 | ); |
| 593 | |
| 594 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(8, 1), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 595 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(3, 0), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 596 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(3, 65), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 597 | |
| 598 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 599 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(3, 33).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 600 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 601 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 602 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b00011111, |
| 603 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 28, |
| 604 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 605 | }, |
| 606 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 607 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111111, |
| 608 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 20, |
| 609 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 610 | }, |
| 611 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 612 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111111, |
| 613 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 12, |
| 614 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 615 | }, |
| 616 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 617 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111111, |
| 618 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 4, |
| 619 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 620 | }, |
| 621 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 622 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11110000, |
| 623 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 624 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 4, |
| 625 | } |
| 626 | ] |
| 627 | ); |
| 628 | |
| 629 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 630 | operationsrust-analyzer cargo pnet_macros 0.35.0 util/operations().(6, 6).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 631 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 632 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 633 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 3, |
| 634 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 4, |
| 635 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 636 | }, |
| 637 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 638 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 240, |
| 639 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 640 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 4, |
| 641 | } |
| 642 | ] |
| 643 | ); |
| 644 | } |
| 645 | |
| 646 | /// Mask `bits` bits of a byte. eg. mask_high_bits(2) == 0b00000011 |
| 647 | fn mask_high_bitsrust-analyzer cargo pnet_macros 0.35.0 util/mask_high_bits().(mut bits: u64) -> u64 { |
| 648 | let mut mask = 0; |
| 649 | while bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().0 { |
| 650 | mask = mask rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOr<Self>`]bitor().(1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<Self>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<Self>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<Self>`]shl().(bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub().1)); |
| 651 | bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign().1; |
| 652 | } |
| 653 | |
| 654 | mask |
| 655 | } |
| 656 | |
| 657 | /// Converts a set of operations which would get a field, to a set of operations which would set |
| 658 | /// the field |
| 659 | /// |
| 660 | /// In the form of (bits to get, bits to set) |
| 661 | pub fn to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(ops: &[GetOperationrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<SetOperationrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#> { |
| 662 | fn num_bits_setrust-analyzer cargo pnet_macros 0.35.0 util/num_bits_set().(n: u8) -> u64 { |
| 663 | let mut count = 0; |
| 664 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8 { |
| 665 | if n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().(1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().i) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().0 { |
| 666 | count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().1; |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | count |
| 671 | } |
| 672 | |
| 673 | let mut sops = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(ops.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 674 | for op in ops { |
| 675 | sops.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(SetOperationrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation# { |
| 676 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][Not]not().op.maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask., |
| 677 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: mask_high_bitsrust-analyzer cargo pnet_macros 0.35.0 util/mask_high_bits().(num_bits_setrust-analyzer cargo pnet_macros 0.35.0 util/num_bits_set().(op.maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl().op.shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl., |
| 678 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: op.shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr., |
| 679 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: op.shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl., |
| 680 | }); |
| 681 | } |
| 682 | |
| 683 | sops |
| 684 | } |
| 685 | |
| 686 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 687 | fn test_to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/test_to_mutator().() { |
| 688 | type Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# = GetOperationrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#; |
| 689 | type Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# = SetOperationrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#; |
| 690 | |
| 691 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 692 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 693 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b10000000, |
| 694 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 695 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 7, |
| 696 | }]), |
| 697 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 698 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b01111111, |
| 699 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00000001, |
| 700 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 7, |
| 701 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 702 | }] |
| 703 | ); |
| 704 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 705 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 706 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11000000, |
| 707 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 708 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 6, |
| 709 | }]), |
| 710 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 711 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00111111, |
| 712 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00000011, |
| 713 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 6, |
| 714 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 715 | }] |
| 716 | ); |
| 717 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 718 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 719 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11100000, |
| 720 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 721 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 5, |
| 722 | }]), |
| 723 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 724 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00011111, |
| 725 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00000111, |
| 726 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 5, |
| 727 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 728 | }] |
| 729 | ); |
| 730 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 731 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 732 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11110000, |
| 733 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 734 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 4, |
| 735 | }]), |
| 736 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 737 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00001111, |
| 738 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00001111, |
| 739 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 4, |
| 740 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 741 | }] |
| 742 | ); |
| 743 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 744 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 745 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111000, |
| 746 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 747 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 3, |
| 748 | }]), |
| 749 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 750 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00000111, |
| 751 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00011111, |
| 752 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 3, |
| 753 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 754 | }] |
| 755 | ); |
| 756 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 757 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 758 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111100, |
| 759 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 760 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 2, |
| 761 | }]), |
| 762 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 763 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00000011, |
| 764 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00111111, |
| 765 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 2, |
| 766 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 767 | }] |
| 768 | ); |
| 769 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 770 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 771 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111110, |
| 772 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 773 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 1, |
| 774 | }]), |
| 775 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 776 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00000001, |
| 777 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b01111111, |
| 778 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 1, |
| 779 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 780 | }] |
| 781 | ); |
| 782 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 783 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 784 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111111, |
| 785 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 786 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 787 | }]), |
| 788 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 789 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00000000, |
| 790 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b11111111, |
| 791 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 0, |
| 792 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 793 | }] |
| 794 | ); |
| 795 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 796 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[ |
| 797 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 798 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111111, |
| 799 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 1, |
| 800 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 801 | }, |
| 802 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 803 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b10000000, |
| 804 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 805 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 7, |
| 806 | } |
| 807 | ]), |
| 808 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 809 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 810 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00000000, |
| 811 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b111111110, |
| 812 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 0, |
| 813 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 1, |
| 814 | }, |
| 815 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 816 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b01111111, |
| 817 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00000001, |
| 818 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 7, |
| 819 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 820 | } |
| 821 | ] |
| 822 | ); |
| 823 | |
| 824 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 825 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[ |
| 826 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 827 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111111, |
| 828 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 2, |
| 829 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 830 | }, |
| 831 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 832 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11000000, |
| 833 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 834 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 6, |
| 835 | } |
| 836 | ]), |
| 837 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 838 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 839 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00000000, |
| 840 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b1111111100, |
| 841 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 0, |
| 842 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 2, |
| 843 | }, |
| 844 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 845 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00111111, |
| 846 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00000011, |
| 847 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 6, |
| 848 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 849 | } |
| 850 | ] |
| 851 | ); |
| 852 | |
| 853 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 854 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 855 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01000000, |
| 856 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 857 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 6, |
| 858 | }]), |
| 859 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 860 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b10111111, |
| 861 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00000001, |
| 862 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 6, |
| 863 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 864 | }] |
| 865 | ); |
| 866 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 867 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 868 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01100000, |
| 869 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 870 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 5, |
| 871 | }]), |
| 872 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 873 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b10011111, |
| 874 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00000011, |
| 875 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 5, |
| 876 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 877 | }] |
| 878 | ); |
| 879 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 880 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 881 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01110000, |
| 882 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 883 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 4, |
| 884 | }]), |
| 885 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 886 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b10001111, |
| 887 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00000111, |
| 888 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 4, |
| 889 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 890 | }] |
| 891 | ); |
| 892 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 893 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 894 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01111000, |
| 895 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 896 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 3, |
| 897 | }]), |
| 898 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 899 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b10000111, |
| 900 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00001111, |
| 901 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 3, |
| 902 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 903 | }] |
| 904 | ); |
| 905 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 906 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 907 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01111100, |
| 908 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 909 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 2, |
| 910 | }]), |
| 911 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 912 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b10000011, |
| 913 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00011111, |
| 914 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 2, |
| 915 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 916 | }] |
| 917 | ); |
| 918 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 919 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 920 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01111110, |
| 921 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 922 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 1, |
| 923 | }]), |
| 924 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 925 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b10000001, |
| 926 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00111111, |
| 927 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 1, |
| 928 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 929 | }] |
| 930 | ); |
| 931 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 932 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 933 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01111111, |
| 934 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 935 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 936 | }]), |
| 937 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 938 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b10000000, |
| 939 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b01111111, |
| 940 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 0, |
| 941 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 942 | }] |
| 943 | ); |
| 944 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 945 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[ |
| 946 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 947 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01111111, |
| 948 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 1, |
| 949 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 950 | }, |
| 951 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 952 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b10000000, |
| 953 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 954 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 7, |
| 955 | } |
| 956 | ]), |
| 957 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 958 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 959 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b10000000, |
| 960 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b11111110, |
| 961 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 0, |
| 962 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 1, |
| 963 | }, |
| 964 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 965 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b01111111, |
| 966 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00000001, |
| 967 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 7, |
| 968 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 969 | } |
| 970 | ] |
| 971 | ); |
| 972 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 973 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[ |
| 974 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 975 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b01111111, |
| 976 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 2, |
| 977 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 978 | }, |
| 979 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 980 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11000000, |
| 981 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 982 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 6, |
| 983 | } |
| 984 | ]), |
| 985 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 986 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 987 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b10000000, |
| 988 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b0111111100, |
| 989 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 0, |
| 990 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 2, |
| 991 | }, |
| 992 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 993 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00111111, |
| 994 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0b00000011, |
| 995 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 6, |
| 996 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 997 | } |
| 998 | ] |
| 999 | ); |
| 1000 | |
| 1001 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1002 | to_mutatorrust-analyzer cargo pnet_macros 0.35.0 util/to_mutator().(&[ |
| 1003 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 1004 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b00011111, |
| 1005 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 28, |
| 1006 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 1007 | }, |
| 1008 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 1009 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111111, |
| 1010 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 20, |
| 1011 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 1012 | }, |
| 1013 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 1014 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111111, |
| 1015 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 12, |
| 1016 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 1017 | }, |
| 1018 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 1019 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11111111, |
| 1020 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 4, |
| 1021 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 0, |
| 1022 | }, |
| 1023 | Oprust-analyzer cargo pnet_macros 0.35.0 util/Op# { |
| 1024 | maskrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#mask.: 0b11110000, |
| 1025 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.: 0, |
| 1026 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftr.: 4, |
| 1027 | } |
| 1028 | ]), |
| 1029 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 1030 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 1031 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b11100000, |
| 1032 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0x1F0000000, |
| 1033 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 0, |
| 1034 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 28, |
| 1035 | }, |
| 1036 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 1037 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00000000, |
| 1038 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0x00FF00000, |
| 1039 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 0, |
| 1040 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 20, |
| 1041 | }, |
| 1042 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 1043 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00000000, |
| 1044 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0x0000FF000, |
| 1045 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 0, |
| 1046 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 12, |
| 1047 | }, |
| 1048 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 1049 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00000000, |
| 1050 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0x000000FF0, |
| 1051 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 0, |
| 1052 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 4, |
| 1053 | }, |
| 1054 | Soprust-analyzer cargo pnet_macros 0.35.0 util/Sop# { |
| 1055 | save_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#save_mask.: 0b00001111, |
| 1056 | value_maskrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#value_mask.: 0x00000000F, |
| 1057 | shiftlrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftl.: 4, |
| 1058 | shiftrrust-analyzer cargo pnet_macros 0.35.0 util/SetOperation#shiftr.: 0, |
| 1059 | } |
| 1060 | ] |
| 1061 | ); |
| 1062 | } |
| 1063 | |
| 1064 | /// Takes a set of operations to get a field in big endian, and converts them to get the field in |
| 1065 | /// little endian. |
| 1066 | pub fn to_little_endianrust-analyzer cargo pnet_macros 0.35.0 util/to_little_endian().(_ops: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<GetOperationrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#>) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<GetOperationrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#> { |
| 1067 | let mut ops = _ops.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().(); |
| 1068 | for (op, be_op) in ops.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(_ops.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().()) { |
| 1069 | op.shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl. = be_op.shiftlrust-analyzer cargo pnet_macros 0.35.0 util/GetOperation#shiftl.; |
| 1070 | } |
| 1071 | ops |
| 1072 | } |