diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa869db..2606737 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,19 +1,111 @@ name: ci + on: - pull_request: push: branches: - - master + - master + pull_request: + +# Cancel redundant workflows on the same branch/PR +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + jobs: - msrv: - name: msrv + fmt: + name: Rustfmt runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@master + + - name: Install toolchain (stable) + rustfmt + uses: dtolnay/rust-toolchain@stable with: - toolchain: 1.70.0 components: rustfmt - - run: cargo fmt --check - - run: cargo check --all-features - - run: cargo test --all-features + + - uses: Swatinem/rust-cache@v2 + + - name: Check formatting + run: cargo fmt --all -- --check + + clippy: + name: Clippy + needs: fmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install toolchain (stable) + clippy + uses: dtolnay/rust-toolchain@stable + with: + components: clippy + + - uses: Swatinem/rust-cache@v2 + + - name: Run clippy + run: cargo clippy --all-features -- -D warnings + + build: + name: Build (${{ matrix.build_type }}) + needs: clippy + runs-on: ubuntu-latest + strategy: + matrix: + include: + - build_type: debug + cargo_profile: dev + - build_type: release + cargo_profile: release + steps: + - uses: actions/checkout@v3 + + - name: Install toolchain (stable) + uses: dtolnay/rust-toolchain@stable + + - uses: Swatinem/rust-cache@v2 + + - name: cargo build + run: cargo build --profile ${{ matrix.cargo_profile }} --all-features + + test: + name: Test + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install toolchain (stable) + uses: dtolnay/rust-toolchain@stable + + - uses: Swatinem/rust-cache@v2 + + - name: Run tests + run: cargo test --all-features + + msrv: + name: MSRV (${{ matrix.build_type }}) + needs: build + runs-on: ubuntu-latest + env: + MSRV: "1.70.0" # if you change it, remember to change it also in Cargo.toml + strategy: + matrix: + include: + - build_type: debug + cargo_profile: dev + - build_type: release + cargo_profile: release + steps: + - uses: actions/checkout@v3 + + - name: Install toolchain (MSRV) + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.MSRV }} + + - uses: Swatinem/rust-cache@v2 + with: + shared-key: "rust-msrv" + + - name: cargo build + run: cargo build --profile ${{ matrix.cargo_profile }} --all-features diff --git a/Cargo.toml b/Cargo.toml index c440f8d..c6a6053 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,9 +6,11 @@ description = "Decode SMBIOS/DMI information into accessible data structures" documentation = "https://docs.rs/dmidecode/" repository = "https://github.com/jcreekmore/dmidecode" license = "MIT" -rust-version = "1.70" edition = "2021" +# if you change it, remember to change it also in ci msrv workflow +rust-version = "1.70" + [dependencies] bitflags = { version = "2.9.1", default-features = false } uuid = { version = "1.17.0", default-features = false } diff --git a/src/bitfield.rs b/src/bitfield.rs index 6878c96..d755228 100644 --- a/src/bitfield.rs +++ b/src/bitfield.rs @@ -142,13 +142,13 @@ impl fmt::Display for Flag<'_> { match self.type_ { FlagType::Significant(meaning, description) => { if f.alternate() { - write!(f, "{}", description) + write!(f, "{description}") } else { - write!(f, "{}", meaning) + write!(f, "{meaning}") } } FlagType::Reserved(note) => { - write!(f, "{}", note) + write!(f, "{note}") } FlagType::Unknown => { write!(f, "Unknown") @@ -385,7 +385,7 @@ mod tests { (7, true, LAYOUT[7]), ]; for i in iter { - println!("{:?}", i); + println!("{i:?}"); } assert_eq!(8, iter.count(), "BYTE setted flags count"); assert_eq!( @@ -400,10 +400,10 @@ mod tests { let iter = Significants::new(Iter::new(0b1010_1001u8, LAYOUT)); let meanings = vec!["A", "C", "E"]; let descriptions = vec!["A Long", "C Long", "E Long"]; - assert_eq!(meanings, iter.map(|v| format!("{}", v)).collect::>(), "Meanings"); + assert_eq!(meanings, iter.map(|v| format!("{v}")).collect::>(), "Meanings"); assert_eq!( descriptions, - iter.map(|v| format!("{:#}", v)).collect::>(), + iter.map(|v| format!("{v:#}")).collect::>(), "Descriptions" ); } @@ -478,34 +478,34 @@ mod tests { .take_while(|&&p| p < 8) .map(|&p| Position(p)) .collect(); - assert_eq!(a, b, "u8:\n{:08b}\n{:08b}", a, b); + assert_eq!(a, b, "u8:\n{a:08b}\n{b:08b}"); let a = 0b0010_1000_1010_1100u16; let b = INDEX_SAMPLE .iter() .take_while(|&&p| p < 16) .map(|&p| Position(p)) .collect(); - assert_eq!(a, b, "u16:\n{:016b}\n{:016b}", a, b); + assert_eq!(a, b, "u16:\n{a:016b}\n{b:016b}"); let a = 2693408940u32; let b = INDEX_SAMPLE .iter() .take_while(|&&p| p < 32) .map(|&p| Position(p)) .collect(); - assert_eq!(a, b, "u32:\n{:032b}\n{:032b}", a, b); + assert_eq!(a, b, "u32:\n{a:032b}\n{b:032b}"); let a = 2891462833508853932u64; let b = INDEX_SAMPLE .iter() .take_while(|&&p| p < 64) .map(|&p| Position(p)) .collect(); - assert_eq!(a, b, "u64:\n{:064b}\n{:064b}", a, b); + assert_eq!(a, b, "u64:\n{a:064b}\n{b:064b}"); let a = 170152392186162032610075049835446806700u128; let b = INDEX_SAMPLE .iter() .take_while(|&&p| p < 128) .map(|&p| Position(p)) .collect(); - assert_eq!(a, b, "u128:\n{:0128b}\n{:0128b}", a, b); + assert_eq!(a, b, "u128:\n{a:0128b}\n{b:0128b}"); } } diff --git a/src/lib.rs b/src/lib.rs index 42584bd..4b6db4b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -320,13 +320,13 @@ impl fmt::Display for InvalidEntryPointError { match self { InvalidEntryPointError::NotFound => write!(f, "Input did not contain a valid SMBIOS entry point"), InvalidEntryPointError::TooOldVersion(version) => { - write!(f, "Input version number was below 2.0: {}", version) + write!(f, "Input version number was below 2.0: {version}") } InvalidEntryPointError::BadSize(size) => { - write!(f, "Input contained an invalid-sized SMBIOS entry: {}", size) + write!(f, "Input contained an invalid-sized SMBIOS entry: {size}") } InvalidEntryPointError::BadChecksum(checksum) => { - write!(f, "SMBIOS entry point has an invalid checksum: {}", checksum) + write!(f, "SMBIOS entry point has an invalid checksum: {checksum}") } } } @@ -410,28 +410,25 @@ impl fmt::Display for MalformedStructureError { MalformedStructureError::BadSize(offset, length) => { write!( f, - "Structure at offset {} with length {} extends beyond SMBIOS", - offset, length + "Structure at offset {offset} with length {length} extends beyond SMBIOS" ) } MalformedStructureError::UnterminatedStrings(offset) => { - write!(f, "Structure at offset {} with unterminated strings", offset) + write!(f, "Structure at offset {offset} with unterminated strings") } MalformedStructureError::InvalidStringIndex(info_type, handle, index) => { write!( f, - "Structure {:?} with handle {} has invalid string index {}", - info_type, handle, index + "Structure {info_type:?} with handle {handle} has invalid string index {index}" ) } MalformedStructureError::InvalidSlice(cause) => { - write!(f, "{}", cause) + write!(f, "{cause}") } MalformedStructureError::InvalidFormattedSectionLength(info_type, handle, spec, length) => { write!( f, - "Formatted section length of structure {:?} with handle {} should be {}{} bytes", - info_type, handle, spec, length + "Formatted section length of structure {info_type:?} with handle {handle} should be {spec}{length} bytes" ) } } @@ -794,7 +791,7 @@ impl fmt::Display for InfoType { //InfoType:: => write!(f, "Processor Additional Information"), //InfoType:: => write!(f, "Inactive"), InfoType::End => write!(f, "End-of-Table"), - InfoType::Oem(t) => write!(f, "OEM: {}", t), + InfoType::Oem(t) => write!(f, "OEM: {t}"), } } } @@ -849,7 +846,7 @@ mod tests { .structures(&DMIDECODE_BIN[(entry_point.smbios_address() as usize)..]) .filter_map(|s| s.ok()) { - println!("{:?}", s); + println!("{s:?}"); } } @@ -857,7 +854,7 @@ mod tests { fn iterator_through_structures_v3_short() { let entry_point = EntryPoint::search(ENTRY_V3_SHORT).unwrap(); for s in entry_point.structures(DMI_V3_SHORT).filter_map(|s| s.ok()) { - println!("{:?}", s); + println!("{s:?}"); } } @@ -865,7 +862,7 @@ mod tests { fn iterator_through_structures_v3() { let entry_point = EntryPoint::search(ENTRY_V3_BIN).unwrap(); for s in entry_point.structures(DMI_V3_BIN).filter_map(|s| s.ok()) { - println!("{:?}", s); + println!("{s:?}"); } } diff --git a/src/structures/000_bios.rs b/src/structures/000_bios.rs index 86f43b1..2bc9c17 100644 --- a/src/structures/000_bios.rs +++ b/src/structures/000_bios.rs @@ -383,13 +383,13 @@ mod tests { let sample = vec!["ISA is supported", "EISA is supported"]; let qword = 0b0101_0000; let iter = Characteristics(qword).significants(); - let result = iter.map(|f| format!("{}", f)).collect::>(); + let result = iter.map(|f| format!("{f}")).collect::>(); assert_eq!( sample, result, "Significant values, default formatting ({:064b})", qword ); - let result = iter.map(|f| format!("{:#}", f)).collect::>(); + let result = iter.map(|f| format!("{f:#}")).collect::>(); assert_eq!( sample, result, "Significant values, alternative formatting ({:064b})", @@ -420,13 +420,13 @@ mod tests { let alt_sample = vec!["ACPI is supported", "1394 boot is supported"]; let byte = 0b0100_0001; let iter = CharacteristicsExtension1(byte).significants(); - let dflt_result = iter.map(|f| format!("{}", f)).collect::>(); + let dflt_result = iter.map(|f| format!("{f}")).collect::>(); assert_eq!( dflt_sample, dflt_result, "Significant values, default formatting ({:08b})", byte ); - let alt_result = iter.map(|f| format!("{:#}", f)).collect::>(); + let alt_result = iter.map(|f| format!("{f:#}")).collect::>(); assert_eq!( alt_sample, alt_result, "Significant values, alternative formatting ({:08b})", @@ -450,13 +450,13 @@ mod tests { let long_sample = vec!["UEFI is supported","SMBIOS table describes a virtual machine. (If this bit is not set, no inference can be made about the virtuality of the system.)"]; let byte = 0b0001_1000; let iter = CharacteristicsExtension2(byte).significants(); - let result = iter.map(|f| format!("{}", f)).collect::>(); + let result = iter.map(|f| format!("{f}")).collect::>(); assert_eq!( short_sample, result, "Significant values, default formatting ({:08b})", byte ); - let result = iter.map(|f| format!("{:#}", f)).collect::>(); + let result = iter.map(|f| format!("{f:#}")).collect::>(); assert_eq!( long_sample, result, "Significant values, alternative formatting ({:08b})", @@ -596,7 +596,7 @@ mod tests { .significants() .chain(bios_result.bios_characteristics_exttension_1.unwrap().significants()) .chain(bios_result.bios_characteristics_exttension_2.unwrap().significants()) - .map(|v| format!("{}", v)) + .map(|v| format!("{v}")) .collect::>(); assert_eq!( all_characteristics_sample, all_char_result, diff --git a/src/structures/002_baseboard.rs b/src/structures/002_baseboard.rs index ff360d9..df02bbd 100644 --- a/src/structures/002_baseboard.rs +++ b/src/structures/002_baseboard.rs @@ -66,7 +66,7 @@ impl fmt::Display for BoardType { BoardType::ProcessorMemoryModule => write!(f, "Processor/Memory Module"), BoardType::ProcessorIoModule => write!(f, "Processor/IO Module"), BoardType::InterconnectBoard => write!(f, "Interconnect board"), - BoardType::Undefined(t) => write!(f, "Undefined: {}", t), + BoardType::Undefined(t) => write!(f, "Undefined: {t}"), } } } diff --git a/src/structures/003_enclosure.rs b/src/structures/003_enclosure.rs index eddd486..a50ede4 100644 --- a/src/structures/003_enclosure.rs +++ b/src/structures/003_enclosure.rs @@ -351,7 +351,7 @@ impl fmt::Display for EnclosureType { Self::EmbeddedPc => write!(f, "Embedded PC"), Self::MiniPc => write!(f, "Mini PC"), Self::StickPc => write!(f, "Stick PC"), - Self::Undefined(v) => write!(f, "Undefined: {}", v), + Self::Undefined(v) => write!(f, "Undefined: {v}"), } } } @@ -378,7 +378,7 @@ impl fmt::Display for State { Self::Warning => write!(f, "Warning"), Self::Critical => write!(f, "Critical"), Self::NonRecoverable => write!(f, "Non-recoverable"), - Self::Undefined(v) => write!(f, "Undefined: {}", v), + Self::Undefined(v) => write!(f, "Undefined: {v}"), } } } @@ -403,7 +403,7 @@ impl fmt::Display for SecurityStatus { Self::None => write!(f, "None"), Self::ExternalInterfaceLockedOut => write!(f, "External interface locked out"), Self::ExternalInterfaceEnabled => write!(f, "External interface enabled"), - Self::Undefined(v) => write!(f, "Undefined: {}", v), + Self::Undefined(v) => write!(f, "Undefined: {v}"), } } } @@ -495,8 +495,8 @@ impl From for ContainedElementType { impl fmt::Display for ContainedElementType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::BoardType(board) => write!(f, "Baseboard type: {}", board), - Self::InfoType(info) => write!(f, "Structure type: {}", info), + Self::BoardType(board) => write!(f, "Baseboard type: {board}"), + Self::InfoType(info) => write!(f, "Structure type: {info}"), } } } @@ -523,11 +523,11 @@ mod tests { 0x09 => (Laptop, "Laptop".into()), 0x18 => (SealedCasePc, "Sealed-case PC".into()), 0x22 => (EmbeddedPc, "Embedded PC".into()), - v @ 0xF0..=0xFF => (Undefined(v), format!("Undefined: {}", v)), + v @ 0xF0..=0xFF => (Undefined(v), format!("Undefined: {v}")), _ => continue, }; - assert_eq!(e, i.into(), "{:#x}", i); - assert_eq!(s, format!("{}", e)); + assert_eq!(e, i.into(), "{i:#x}"); + assert_eq!(s, format!("{e}")); } } @@ -539,11 +539,11 @@ mod tests { 0x01 => (Other, "Other".into()), 0x04 => (Warning, "Warning".into()), 0x06 => (NonRecoverable, "Non-recoverable".into()), - v @ 0xF0..=0xFF => (Undefined(v), format!("Undefined: {}", v)), + v @ 0xF0..=0xFF => (Undefined(v), format!("Undefined: {v}")), _ => continue, }; - assert_eq!(e, i.into(), "{:#x}", i); - assert_eq!(s, format!("{}", e)); + assert_eq!(e, i.into(), "{i:#x}"); + assert_eq!(s, format!("{e}")); } } @@ -555,11 +555,11 @@ mod tests { 0x01 => (Other, "Other".into()), 0x03 => (None, "None".into()), 0x05 => (ExternalInterfaceEnabled, "External interface enabled".into()), - v @ 0xF0..=0xFF => (Undefined(v), format!("Undefined: {}", v)), + v @ 0xF0..=0xFF => (Undefined(v), format!("Undefined: {v}")), _ => continue, }; - assert_eq!(e, i.into(), "{:#x}", i); - assert_eq!(s, format!("{}", e)); + assert_eq!(e, i.into(), "{i:#x}"); + assert_eq!(s, format!("{e}")); } } @@ -591,7 +591,7 @@ mod tests { for (array, contained_element, display) in data { let v = &ContainedElement::from(&array[..]); assert_eq!(contained_element, v); - assert_eq!(format!("{}", display), format!("{}", v)); + assert_eq!(format!("{display}"), format!("{}", v)); } } @@ -677,27 +677,27 @@ mod tests { assert_eq!(format!("{}", enc.serial_number), "XXXXXXX", "Serial Number"); assert_eq!(format!("{}", enc.asset_tag_number), "", "Asset Tag"); assert_eq!( - enc.boot_up_state.map(|v| format!("{}", v)), + enc.boot_up_state.map(|v| format!("{v}")), Some("Safe".into()), "Boot-up State" ); assert_eq!( - enc.power_supply_state.map(|v| format!("{}", v)), + enc.power_supply_state.map(|v| format!("{v}")), Some("Safe".into()), "Power Supply State" ); assert_eq!( - enc.thermal_state.map(|v| format!("{}", v)), + enc.thermal_state.map(|v| format!("{v}")), Some("Safe".into()), "Thermal State" ); assert_eq!( - enc.security_status.map(|v| format!("{}", v)), + enc.security_status.map(|v| format!("{v}")), Some("Unknown".into()), "Security Status" ); assert_eq!( - enc.oem_defined.map(|v| format!("{:#010X}", v)), + enc.oem_defined.map(|v| format!("{v:#010X}")), Some("0x01010101".into()), "OEM Information" ); @@ -706,14 +706,14 @@ mod tests { assert_eq!( enc.contained_elements .clone() - .and_then(|mut ce| ce.next().map(|s| format!("{}", s))), + .and_then(|mut ce| ce.next().map(|s| format!("{s}"))), Some("Structure type: Memory Device (1-2)".into()), "Number Of Power Cords" ); assert_eq!( enc.contained_elements .clone() - .and_then(|mut ce| ce.nth(1).map(|s| format!("{}", s))), + .and_then(|mut ce| ce.nth(1).map(|s| format!("{s}"))), Some("Baseboard type: Server Blade (255-0)".into()), "Number Of Power Cords" ); diff --git a/src/structures/004_processor.rs b/src/structures/004_processor.rs index 4dabf80..7489fd0 100644 --- a/src/structures/004_processor.rs +++ b/src/structures/004_processor.rs @@ -1457,8 +1457,8 @@ impl fmt::Display for ProcessorFamily { ProcessorFamily::ProcessorFamily2 => { write!(f, "Processor Family 2 has the enumerated value") } - ProcessorFamily::Available(n) => write!(f, "Available {:#X}", n), - ProcessorFamily::NotUsed(n) => write!(f, "Not used. {:X}h is the un-initialized value of Flash memory.", n), + ProcessorFamily::Available(n) => write!(f, "Available {n:#X}"), + ProcessorFamily::NotUsed(n) => write!(f, "Not used. {n:X}h is the un-initialized value of Flash memory."), ProcessorFamily::OutOfSpec => write!(f, "OUT OF SPEC"), } } @@ -1481,7 +1481,7 @@ impl fmt::Display for Voltage { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Current(v) => write!(f, "Current voltage: {:.1} V", *v as f32 / 10.0), - Self::Undefined(n) => write!(f, "Undefined {:#b}", n), + Self::Undefined(n) => write!(f, "Undefined {n:#b}"), Self::Legacy(legacy) => { let s55 = if legacy.contains(VoltageLegacy::VOLTAGE_CAPABILITY_5V0) { "5.5V " @@ -1501,7 +1501,7 @@ impl fmt::Display for Voltage { if s55.is_empty() && s33.is_empty() && s29.is_empty() { write!(f, "Voltage capability unknown") } else { - write!(f, "Processor socket accept: {}{}{}", s55, s33, s29) + write!(f, "Processor socket accept: {s55}{s33}{s29}") } } } @@ -1642,7 +1642,7 @@ impl fmt::Display for ProcessorUpgrade { ProcessorUpgrade::SocketBGA1528 => write!(f, "Socket BGA1528"), ProcessorUpgrade::SocketLGA4189 => write!(f, "Socket LGA4189"), ProcessorUpgrade::SocketLGA1200 => write!(f, "Socket LGA1200"), - ProcessorUpgrade::Undefined(n) => write!(f, "Undefined {}", n), + ProcessorUpgrade::Undefined(n) => write!(f, "Undefined {n}"), } } } @@ -1678,33 +1678,33 @@ mod tests { 0x104 => (SH3, "SH-3".into()), 0x118 => (ARM, "ARM".into()), 0x140 => (WinChip, "WinChip".into()), - n @ 0x16..=0x17 => (Available(n), format!("Available {:#X}", n)), - n @ 0x59..=0x5F => (Available(n), format!("Available {:#X}", n)), - n @ 0x6C..=0x6F => (Available(n), format!("Available {:#X}", n)), - n @ 0x71..=0x77 => (Available(n), format!("Available {:#X}", n)), - n @ 0x7B..=0x7F => (Available(n), format!("Available {:#X}", n)), - n @ 0x81 => (Available(n), format!("Available {:#X}", n)), - n @ 0x97..=0x9F => (Available(n), format!("Available {:#X}", n)), - n @ 0xD0..=0xD1 => (Available(n), format!("Available {:#X}", n)), - n @ 0xDC => (Available(n), format!("Available {:#X}", n)), - n @ 0xE1..=0xE3 => (Available(n), format!("Available {:#X}", n)), - n @ 0xF0..=0xF9 => (Available(n), format!("Available {:#X}", n)), - n @ 0xFC..=0xFD => (Available(n), format!("Available {:#X}", n)), - n @ 0x1F5..=0x1FF => (Available(n), format!("Available {:#X}", n)), - n @ 0x203..=0xFFFD => (Available(n), format!("Available {:#X}", n)), + n @ 0x16..=0x17 => (Available(n), format!("Available {n:#X}")), + n @ 0x59..=0x5F => (Available(n), format!("Available {n:#X}")), + n @ 0x6C..=0x6F => (Available(n), format!("Available {n:#X}")), + n @ 0x71..=0x77 => (Available(n), format!("Available {n:#X}")), + n @ 0x7B..=0x7F => (Available(n), format!("Available {n:#X}")), + n @ 0x81 => (Available(n), format!("Available {n:#X}")), + n @ 0x97..=0x9F => (Available(n), format!("Available {n:#X}")), + n @ 0xD0..=0xD1 => (Available(n), format!("Available {n:#X}")), + n @ 0xDC => (Available(n), format!("Available {n:#X}")), + n @ 0xE1..=0xE3 => (Available(n), format!("Available {n:#X}")), + n @ 0xF0..=0xF9 => (Available(n), format!("Available {n:#X}")), + n @ 0xFC..=0xFD => (Available(n), format!("Available {n:#X}")), + n @ 0x1F5..=0x1FF => (Available(n), format!("Available {n:#X}")), + n @ 0x203..=0xFFFD => (Available(n), format!("Available {n:#X}")), n @ 0xFF => ( NotUsed(n), - format!("Not used. {:X}h is the un-initialized value of Flash memory.", n), + format!("Not used. {n:X}h is the un-initialized value of Flash memory."), ), 0xFFFE => (ForFutureUse, "For special use in the future".into()), n @ 0xFFFF => ( NotUsed(n), - format!("Not used. {:X}h is the un-initialized value of Flash memory.", n), + format!("Not used. {n:X}h is the un-initialized value of Flash memory."), ), _ => continue, }; - assert_eq!(e, i.into(), "{:#x}", i); - assert_eq!(s, format!("{}", e)); + assert_eq!(e, i.into(), "{i:#x}"); + assert_eq!(s, format!("{e}")); } } @@ -1741,8 +1741,8 @@ mod tests { ]; for (byte, sample, display) in test_data.iter() { let result = Voltage::from(*byte); - assert_eq!(*sample, result, "Byte: {:#b}", byte); - assert_eq!(format!("{}", result), format!("{}", display), "Byte: {:#b}", byte); + assert_eq!(*sample, result, "Byte: {byte:#b}"); + assert_eq!(format!("{result}"), format!("{}", display), "Byte: {:#b}", byte); } } @@ -1756,11 +1756,11 @@ mod tests { 0x18 => (SocketF, "Socket F (1207)".into()), 0x2B => (SocketLGA2011Three, "Socket LGA2011-3".into()), 0x3E => (SocketLGA1200, "Socket LGA1200".into()), - n @ 0x3F..=0xFF => (Undefined(n), format!("Undefined {}", n)), + n @ 0x3F..=0xFF => (Undefined(n), format!("Undefined {n}")), _ => continue, }; - assert_eq!(e, i.into(), "{:#x}", i); - assert_eq!(s, format!("{}", e)); + assert_eq!(e, i.into(), "{i:#x}"); + assert_eq!(s, format!("{e}")); } } diff --git a/src/structures/007_cache.rs b/src/structures/007_cache.rs index db1ab72..7b1c8b7 100644 --- a/src/structures/007_cache.rs +++ b/src/structures/007_cache.rs @@ -398,7 +398,7 @@ impl fmt::Display for CacheErrorCorrectionType { Self::Parity => write!(f, "Parity"), Self::SingleBitEcc => write!(f, "Single-bit ECC"), Self::MultiBitEcc => write!(f, "Multi-bit ECC"), - Self::Undefined(t) => write!(f, "Undefined: {}", t), + Self::Undefined(t) => write!(f, "Undefined: {t}"), } } } @@ -423,7 +423,7 @@ impl fmt::Display for SystemCacheType { Self::Instruction => write!(f, "Instruction"), Self::Data => write!(f, "Data"), Self::Unified => write!(f, "Unified"), - Self::Undefined(t) => write!(f, "Undefined: {}", t), + Self::Undefined(t) => write!(f, "Undefined: {t}"), } } } @@ -466,7 +466,7 @@ impl fmt::Display for CacheAssociativity { Self::FourtyEightWaySetAssociative => write!(f, "48-way Set-Associative"), Self::SixtyFourWaySetAssociative => write!(f, "64-way Set-Associative"), Self::TwentyWaySetAssociative => write!(f, "20-way Set-Associative"), - Self::Undefined(t) => write!(f, "Undefined: {}", t), + Self::Undefined(t) => write!(f, "Undefined: {t}"), } } } diff --git a/src/structures/008_port_connector.rs b/src/structures/008_port_connector.rs index c57900c..cc5ea1e 100644 --- a/src/structures/008_port_connector.rs +++ b/src/structures/008_port_connector.rs @@ -243,7 +243,7 @@ impl fmt::Display for ConnectorType { Self::Pc98Note => write!(f, "PC-98Note"), Self::Pc98Full => write!(f, "PC-98Full"), Self::Other => write!(f, "Other – Use Reference Designator Strings to supply information."), - Self::Undefined(v) => write!(f, "Undefined: {}", v), + Self::Undefined(v) => write!(f, "Undefined: {v}"), } } } @@ -336,7 +336,7 @@ impl fmt::Display for PortType { PortType::Intel8251Compatible => write!(f, "8251 Compatible"), PortType::Intel8251FifoCompatible => write!(f, "8251 FIFO Compatible"), PortType::Other => write!(f, "Other"), - PortType::Undefined(v) => write!(f, "Undefined: {}", v), + PortType::Undefined(v) => write!(f, "Undefined: {v}"), } } } @@ -362,7 +362,7 @@ mod test { let result = samples.iter().map(|v| Into::into(v.0)).collect::>(); assert_eq!( samples.iter().map(|(_, v, s)| (v, (*s).into())).collect::>(), - result.iter().map(|r| (r, format!("{}", r))).collect::>(), + result.iter().map(|r| (r, format!("{r}"))).collect::>(), ); } #[test] @@ -378,7 +378,7 @@ mod test { let result = samples.iter().map(|v| Into::into(v.0)).collect::>(); assert_eq!( samples.iter().map(|(_, v, s)| (v, (*s).into())).collect::>(), - result.iter().map(|r| (r, format!("{}", r))).collect::>(), + result.iter().map(|r| (r, format!("{r}"))).collect::>(), ); } #[test] diff --git a/src/structures/009_system_slots.rs b/src/structures/009_system_slots.rs index fd9f438..e603dfa 100644 --- a/src/structures/009_system_slots.rs +++ b/src/structures/009_system_slots.rs @@ -626,7 +626,7 @@ impl fmt::Display for SlotType { write!(f, "EDSFF E3") } } - Self::Undefined(v) => write!(f, "Undefined: {}", v), + Self::Undefined(v) => write!(f, "Undefined: {v}"), } } } @@ -669,7 +669,7 @@ impl fmt::Display for SlotWidth { Self::X12 => write!(f, "12x or x12"), Self::X16 => write!(f, "16x or x16"), Self::X32 => write!(f, "32x or x32"), - Self::Undefined(v) => write!(f, "Undefined: {}", v), + Self::Undefined(v) => write!(f, "Undefined: {v}"), } } } @@ -701,7 +701,7 @@ impl fmt::Display for CurrentUsage { write!(f, "Unavailable") } } - Self::Undefined(v) => write!(f, "Undefined: {}", v), + Self::Undefined(v) => write!(f, "Undefined: {v}"), } } } @@ -728,7 +728,7 @@ impl fmt::Display for SlotLength { Self::LongLength => write!(f, "Long Length"), Self::DriveFormFactor2_5 => write!(f, "2.5\" drive form factor"), Self::DriveFormFactor3_5 => write!(f, "3.5\" drive form factor"), - Self::Undefined(v) => write!(f, "Undefined: {}", v), + Self::Undefined(v) => write!(f, "Undefined: {v}"), } } } @@ -918,7 +918,7 @@ mod tests { .collect::>(), result .iter() - .map(|r| (r, format!("{}", r), format!("{:#}", r))) + .map(|r| (r, format!("{r}"), format!("{r:#}"))) .collect::>(), ); } @@ -937,7 +937,7 @@ mod tests { let result = samples.iter().map(|v| Into::into(v.0)).collect::>(); assert_eq!( samples.iter().map(|(_, v, s)| (v, (*s).into())).collect::>(), - result.iter().map(|r| (r, format!("{}", r))).collect::>(), + result.iter().map(|r| (r, format!("{r}"))).collect::>(), ); } @@ -958,7 +958,7 @@ mod tests { let result = samples.iter().map(|v| Into::into(v.0)).collect::>(); assert_eq!( samples.iter().map(|(_, v, s)| (v, (*s).into())).collect::>(), - result.iter().map(|r| (r, format!("{:#}", r))).collect::>(), + result.iter().map(|r| (r, format!("{r:#}"))).collect::>(), ); } @@ -975,7 +975,7 @@ mod tests { let result = samples.iter().map(|v| Into::into(v.0)).collect::>(); assert_eq!( samples.iter().map(|(_, v, s)| (v, (*s).into())).collect::>(), - result.iter().map(|r| (r, format!("{:}", r))).collect::>(), + result.iter().map(|r| (r, format!("{r:}"))).collect::>(), ); } @@ -995,13 +995,13 @@ mod tests { let alt_sample = vec!["Provides 5.0 volts", "PC Card slot supports Modem Ring Resume"]; let byte = 0b1000_0010; let iter = SlotCharacteristics1(byte).significants(); - let dflt_result = iter.map(|f| format!("{}", f)).collect::>(); + let dflt_result = iter.map(|f| format!("{f}")).collect::>(); assert_eq!( dflt_sample, dflt_result, "Significant values, default formatting ({:08b})", byte ); - let alt_result = iter.map(|f| format!("{:#}", f)).collect::>(); + let alt_result = iter.map(|f| format!("{f:#}")).collect::>(); assert_eq!( alt_sample, alt_result, "Significant values, alternative formatting ({:08b})", @@ -1028,13 +1028,13 @@ mod tests { let alt_sample = vec!["PCI slot supports Power Management Event (PME#) signal","Slot supports async/surprise removal (i.e., removal without prior notification to the operating system, device driver, or applications)"]; let byte = 0b0001_0001; let iter = SlotCharacteristics2(byte).significants(); - let dflt_result = iter.map(|f| format!("{}", f)).collect::>(); + let dflt_result = iter.map(|f| format!("{f}")).collect::>(); assert_eq!( dflt_sample, dflt_result, "Significant values, default formatting ({:08b})", byte ); - let alt_result = iter.map(|f| format!("{:#}", f)).collect::>(); + let alt_result = iter.map(|f| format!("{f:#}")).collect::>(); assert_eq!( alt_sample, alt_result, "Significant values, alternative formatting ({:08b})", @@ -1072,7 +1072,7 @@ mod tests { .iter() .map(|v| v.to_string()) .collect(); - assert_eq!(display_sample, result.map(|v| format!("{}", v)).collect::>()); + assert_eq!(display_sample, result.map(|v| format!("{v}")).collect::>()); } #[test] @@ -1235,7 +1235,7 @@ mod tests { .structures(&DMIDECODE_BIN[(entry_point.smbios_address() as usize)..]) .filter_map(|s| { if let Err(ref s) = s { - println!("{}", s); + println!("{s}"); } s.ok().filter(|s| matches!(s, Structure::SystemSlots(_))) }) diff --git a/src/structures/011_oem_strings.rs b/src/structures/011_oem_strings.rs index e52213a..0d08db1 100644 --- a/src/structures/011_oem_strings.rs +++ b/src/structures/011_oem_strings.rs @@ -67,7 +67,7 @@ mod tests { .structures(&DMIDECODE_BIN[(entry_point.smbios_address() as usize)..]) .filter_map(|s| { if let Err(ref s) = s { - println!("{}", s); + println!("{s}"); } s.ok().filter(|s| matches!(s, Structure::OemStrings(_))) }) diff --git a/src/structures/012_system_configuration_options.rs b/src/structures/012_system_configuration_options.rs index 629be4a..5f8aa45 100644 --- a/src/structures/012_system_configuration_options.rs +++ b/src/structures/012_system_configuration_options.rs @@ -81,7 +81,7 @@ mod tests { .structures(&DMIDECODE_BIN[(entry_point.smbios_address() as usize)..]) .filter_map(|s| { if let Err(ref s) = s { - println!("{}", s); + println!("{s}"); } s.ok().filter(|s| matches!(s, Structure::SystemConfigurationOptions(_))) }) diff --git a/src/structures/015_system_event_log/log_record_format.rs b/src/structures/015_system_event_log/log_record_format.rs index e7bae06..d447b73 100644 --- a/src/structures/015_system_event_log/log_record_format.rs +++ b/src/structures/015_system_event_log/log_record_format.rs @@ -284,7 +284,7 @@ impl From for u8 { impl fmt::Display for EventLogType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match (f.alternate(), self) { - (true, Self::Reserved(v)) => write!(f, "Reserved: {}", v), + (true, Self::Reserved(v)) => write!(f, "Reserved: {v}"), (false, Self::Reserved(_)) => write!(f, "Reserved"), (_, Self::SingleBitEccMemoryError) => write!(f, "Single-bit ECC memory error"), (_, Self::MultiBitEccMemoryError) => write!(f, "Multi-bit ECC memory error"), @@ -329,8 +329,8 @@ impl fmt::Display for EventLogType { (true, Self::LogAreaReset) => write!(f, "Log Area Reset/Cleared"), (false, Self::LogAreaReset) => write!(f, "Log area reset/cleared"), (_, Self::SystemBoot) => write!(f, "System boot"), - (_, Self::Unused(v)) => write!(f, "Unused: {}", v), - (true, Self::Available(v)) => write!(f, "Available for system- and OEM-specific assignments: {}", v), + (_, Self::Unused(v)) => write!(f, "Unused: {v}"), + (true, Self::Available(v)) => write!(f, "Available for system- and OEM-specific assignments: {v}"), (false, Self::Available(_)) => write!(f, "OEM-specific"), (_, Self::EndOfLog) => write!(f, "End of log"), } @@ -376,20 +376,20 @@ impl fmt::Display for VariableDataFormatType { (true, Self::None) => write!(f, "No standard format data is available"), (false, Self::None) => write!(f, "None"), (true, Self::Handle { handle }) => { - write!(f, "SMBIOS structure associated handle: {}", handle) + write!(f, "SMBIOS structure associated handle: {handle}") } (false, Self::Handle { .. }) => write!(f, "Handle"), (true, Self::MultipleEvent { counter }) => { - write!(f, "Multiple-event counter value: {}", counter) + write!(f, "Multiple-event counter value: {counter}") } (false, Self::MultipleEvent { .. }) => write!(f, "Multiple-event"), (true, Self::MultipleEventHandle { handle, counter }) => { - write!(f, "Multiple-event: Handle 0x{:04X}, Count {}", handle, counter) + write!(f, "Multiple-event: Handle 0x{handle:04X}, Count {counter}") } (false, Self::MultipleEventHandle { .. }) => write!(f, "Multiple-event handle"), (true, Self::PostResults(pr)) => write!(f, "POST result: {:#X}", pr.0), (false, Self::PostResults(_)) => write!(f, "POST results bitmap"), - (true, Self::SystemManagementType(sm)) => write!(f, "System management: {}", sm), + (true, Self::SystemManagementType(sm)) => write!(f, "System management: {sm}"), (false, Self::SystemManagementType(_)) => write!(f, "System management"), ( true, @@ -399,14 +399,13 @@ impl fmt::Display for VariableDataFormatType { }, ) => write!( f, - "Multiple-event system management: Type {}, Count {}", - system_management_type, counter + "Multiple-event system management: Type {system_management_type}, Count {counter}" ), (false, Self::MultipleEventSystemManagementType { .. }) => { write!(f, "Multiple-event system management") } - (_, Self::Unused(v)) => write!(f, "Unused: {}", v), - (true, Self::OemAssigned(v)) => write!(f, "OEM assigned: {}", v), + (_, Self::Unused(v)) => write!(f, "Unused: {v}"), + (true, Self::OemAssigned(v)) => write!(f, "OEM assigned: {v}"), (false, Self::OemAssigned(_)) => write!(f, "OEM-specific"), } } @@ -511,7 +510,7 @@ impl fmt::Display for SystemManagementType { Self::OutOfRangeVoltageMinus5 => write!(f, "-5V Out of range"), Self::OutOfRangeVoltagePlus12 => write!(f, "+12V Out of range"), Self::OutOfRangeVoltageMinus12 => write!(f, "-12V Out of range"), - Self::OutOfRangeVoltageReserved(v) => write!(f, "Out-of-range voltage reserved: {}", v), + Self::OutOfRangeVoltageReserved(v) => write!(f, "Out-of-range voltage reserved: {v}"), Self::OutOfRangeTemperatureSystemBoard => { write!(f, "System board temperature out of range") } @@ -528,17 +527,16 @@ impl fmt::Display for SystemManagementType { write!(f, "Processor #4 temperature out of range") } Self::OutOfRangeTemperatureReserved(v) => { - write!(f, "Out-of-range temperatures reserved: {}", v) + write!(f, "Out-of-range temperatures reserved: {v}") } - Self::OutOfRangeFan(v) => write!(f, "Fan {} Out of range", v), + Self::OutOfRangeFan(v) => write!(f, "Fan {v} Out of range"), Self::ChassisSecureSwitchActivated => write!(f, "Chassis secure switch activated"), Self::OutOfRangeSystemManagementProbe(v) => write!( f, - "A system-management probe or cooling device with handle 0x{:04X} is out of range", - v + "A system-management probe or cooling device with handle 0x{v:04X} is out of range" ), - Self::OemAssigned(v) => write!(f, "OEM assigned: {}", v), - Self::Reserved(v) => write!(f, "Reserved: {}", v), + Self::OemAssigned(v) => write!(f, "OEM assigned: {v}"), + Self::Reserved(v) => write!(f, "Reserved: {v}"), } } } @@ -574,7 +572,7 @@ mod tests { assert_eq!(enum_sample, result, "Enum variants"); assert_eq!( display_sample, - result.iter().map(|v| format!("{}", v)).collect::>(), + result.iter().map(|v| format!("{v}")).collect::>(), "Enum variants" ); } @@ -599,7 +597,7 @@ mod tests { ]; assert_eq!( significant_sample, - pr.significants().map(|v| format!("{}", v)).collect::>(), + pr.significants().map(|v| format!("{v}")).collect::>(), "Significants" ); assert_eq!( @@ -607,7 +605,7 @@ mod tests { pr.iter() .filter_map(|f| { if f.is_set && matches!(f.type_, Reserved(_)) { - Some((f.position, format!("{}", f))) + Some((f.position, format!("{f}"))) } else { None } diff --git a/src/structures/015_system_event_log/mod.rs b/src/structures/015_system_event_log/mod.rs index 12abbc5..b64cefe 100644 --- a/src/structures/015_system_event_log/mod.rs +++ b/src/structures/015_system_event_log/mod.rs @@ -281,39 +281,33 @@ impl fmt::Display for AccessMethod { (false, Self::GeneralPurposeNonVolatileData { .. }) => { write!(f, "General-purpose non-volatile data functions") } - (false, Self::OemSpecific { method, .. }) => write!(f, "OEM-specific: {}", method), - (false, Self::Available { method, .. }) => write!(f, "Available: {}", method), + (false, Self::OemSpecific { method, .. }) => write!(f, "OEM-specific: {method}"), + (false, Self::Available { method, .. }) => write!(f, "Available: {method}"), // With address (true, Self::IndexedIoOne8bitIndexOne8bitData { index, data }) => write!( f, - "Indexed I/O, one 8-bit index port, one 8-bit data port: Index 0x{:02X}, Data 0x{:02X}", - index, data + "Indexed I/O, one 8-bit index port, one 8-bit data port: Index 0x{index:02X}, Data 0x{data:02X}" ), (true, Self::IndexedIoTwo8bitIndexOne8bitData { index, data }) => write!( f, - "Indexed I/O, two 8-bit index ports, one 8-bit data port: Index {:X?}, Data 0x{:02X}", - index, data + "Indexed I/O, two 8-bit index ports, one 8-bit data port: Index {index:X?}, Data 0x{data:02X}" ), (true, Self::IndexedIoOne16bitIndexOne8bitData { index, data }) => write!( f, - "Indexed I/O, one 16-bit index port, one 8-bit data port: Index 0x{:04X}, Data 0x{:02X}", - index, data + "Indexed I/O, one 16-bit index port, one 8-bit data port: Index 0x{index:04X}, Data 0x{data:02X}" ), (true, Self::MemoryMappedPhysicaAddress { physical_address }) => { - write!(f, "Memory-mapped physical 32-bit address: 0x{:08X}", physical_address) + write!(f, "Memory-mapped physical 32-bit address: 0x{physical_address:08X}") } (true, Self::GeneralPurposeNonVolatileData { gpnv_handle }) => write!( f, - "General-Purpose NonVolatile Data functions, handle 0x{:04X}", - gpnv_handle - ), - (true, Self::OemSpecific { method, address }) => write!( - f, - "BIOS Vendor/OEM-specific: Method {}, Address 0x{:08X}", - method, address + "General-Purpose NonVolatile Data functions, handle 0x{gpnv_handle:04X}" ), + (true, Self::OemSpecific { method, address }) => { + write!(f, "BIOS Vendor/OEM-specific: Method {method}, Address 0x{address:08X}") + } (true, Self::Available { method, address }) => { - write!(f, "Available: Method {}, Address 0x{:08X}", method, address) + write!(f, "Available: Method {method}, Address 0x{address:08X}") } } } @@ -353,9 +347,9 @@ impl fmt::Display for LogHeaderFormat { (_, Self::NoHeader) => write!(f, "No Header"), (true, Self::LogHeaderType1) => write!(f, "Type 1 log header"), (false, Self::LogHeaderType1) => write!(f, "Type 1"), - (true, Self::OemSpecific(v)) => write!(f, "BIOS vendor or OEM-specific format: {}", v), + (true, Self::OemSpecific(v)) => write!(f, "BIOS vendor or OEM-specific format: {v}"), (false, Self::OemSpecific(_)) => write!(f, "OEM-specific"), - (_, Self::Available(v)) => write!(f, "Available: {}", v), + (_, Self::Available(v)) => write!(f, "Available: {v}"), } } } @@ -443,10 +437,7 @@ mod tests { let byte: u8 = 0b111; let ls: LogStatus = byte.into(); let sample = vec!["Log area valid", "Log area full"]; - assert_eq!( - sample, - ls.significants().map(|v| format!("{:#}", v)).collect::>() - ); + assert_eq!(sample, ls.significants().map(|v| format!("{v:#}")).collect::>()); } #[test] diff --git a/src/structures/016_physical_memory_array.rs b/src/structures/016_physical_memory_array.rs index 49b99db..f3bed39 100644 --- a/src/structures/016_physical_memory_array.rs +++ b/src/structures/016_physical_memory_array.rs @@ -75,7 +75,7 @@ impl fmt::Display for MemoryArrayLocation { Self::Pc98eAddOnCard => write!(f, "PC-98/E add-on card"), Self::Pc98LocalBusAddOnCard => write!(f, "PC-98/Local bus add-on card"), Self::CxlAddOnCard => write!(f, "CXL add-on card"), - Self::Undefined(t) => write!(f, "Undefined: {}", t), + Self::Undefined(t) => write!(f, "Undefined: {t}"), } } } @@ -123,7 +123,7 @@ impl fmt::Display for MemoryArrayUse { Self::FlashMemory => write!(f, "Flash memory"), Self::NonVolatileRam => write!(f, "Non-volatile RAM"), Self::CacheMemory => write!(f, "Cache memory"), - Self::Undefined(t) => write!(f, "Undefined: {}", t), + Self::Undefined(t) => write!(f, "Undefined: {t}"), } } } @@ -171,7 +171,7 @@ impl fmt::Display for MemoryArrayErrorCorrectionTypes { Self::SingleBitEcc => write!(f, "Single-bit ECC"), Self::MultiBitEcc => write!(f, "Multi-bit ECC"), Self::CRC => write!(f, "CRC"), - Self::Undefined(t) => write!(f, "Undefined: {}", t), + Self::Undefined(t) => write!(f, "Undefined: {t}"), } } } diff --git a/src/structures/018_memory_error_32.rs b/src/structures/018_memory_error_32.rs index 7025e33..898096e 100644 --- a/src/structures/018_memory_error_32.rs +++ b/src/structures/018_memory_error_32.rs @@ -137,7 +137,7 @@ impl fmt::Display for ErrorType { Self::CorrectedSingleBitError => write!(f, "Corrected single-bit error"), Self::CorrectedError => write!(f, "Corrected error"), Self::UncorrectableError => write!(f, "Uncorrectable error"), - Self::Undefined(v) => write!(f, "Undefined: {}", v), + Self::Undefined(v) => write!(f, "Undefined: {v}"), } } } @@ -160,7 +160,7 @@ impl fmt::Display for ErrorGranularity { Self::Unknown => write!(f, "Unknown"), Self::DeviceLevel => write!(f, "Device level"), Self::MemoryPartitionLevel => write!(f, "Memory partition level"), - Self::Undefined(v) => write!(f, "Undefined: {}", v), + Self::Undefined(v) => write!(f, "Undefined: {v}"), } } } @@ -185,7 +185,7 @@ impl fmt::Display for ErrorOperation { Self::Read => write!(f, "Read"), Self::Write => write!(f, "Write"), Self::PartialWrite => write!(f, "Partial write"), - Self::Undefined(v) => write!(f, "Undefined: {}", v), + Self::Undefined(v) => write!(f, "Undefined: {v}"), } } } diff --git a/src/structures/021_built_in_pointing_device.rs b/src/structures/021_built_in_pointing_device.rs index 1c06e75..57effed 100644 --- a/src/structures/021_built_in_pointing_device.rs +++ b/src/structures/021_built_in_pointing_device.rs @@ -110,7 +110,7 @@ impl fmt::Display for Type { Self::TouchPad => write!(f, "Touch Pad"), Self::TouchScreen => write!(f, "Touch Screen"), Self::OpticalSensor => write!(f, "Optical Sensor"), - Self::Undefined(v) => write!(f, "Undefined: {}", v), + Self::Undefined(v) => write!(f, "Undefined: {v}"), } } } @@ -147,7 +147,7 @@ impl fmt::Display for Interface { Self::BusMouseDb9 => write!(f, "Bus mouse DB-9"), Self::BusMouseMicroDin => write!(f, "Bus mouse micro-DIN"), Self::Usb => write!(f, "USB"), - Self::Undefined(v) => write!(f, "Undefined: {}", v), + Self::Undefined(v) => write!(f, "Undefined: {v}"), } } } diff --git a/src/structures/022_portable_battery.rs b/src/structures/022_portable_battery.rs index 8964f9d..ac14057 100644 --- a/src/structures/022_portable_battery.rs +++ b/src/structures/022_portable_battery.rs @@ -153,11 +153,11 @@ impl fmt::Display for ManufactureDate<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::None => Ok(()), - Self::Basic(s) => write!(f, "{}", s), + Self::Basic(s) => write!(f, "{s}"), Self::SmartBatteryDataSpecification { year, month, date } => // ISO 8601 { - write!(f, "{:04}-{:02}-{:02}", year, month, date) + write!(f, "{year:04}-{month:02}-{date:02}") } } } @@ -176,8 +176,8 @@ impl fmt::Display for SerialNumber<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::None => Ok(()), - Self::Basic(s) => write!(f, "{}", s), - Self::SmartBatteryDataSpecification(word) => write!(f, "{:#04X}", word), + Self::Basic(s) => write!(f, "{s}"), + Self::SmartBatteryDataSpecification(word) => write!(f, "{word:#04X}"), } } } @@ -214,8 +214,8 @@ impl fmt::Display for DeviceChemistry<'_> { Self::LithiumIon => write!(f, "Lithium-ion"), Self::ZincAir => write!(f, "Zinc air"), Self::LithiumPolymer => write!(f, "Lithium Polymer"), - Self::Undefined(v) => write!(f, "Undefined: {}", v), - Self::SmartBatteryDataSpecification(s) => write!(f, "{}", s), + Self::Undefined(v) => write!(f, "Undefined: {v}"), + Self::SmartBatteryDataSpecification(s) => write!(f, "{s}"), } } }