Skip to content

Commit 3660f9d

Browse files
committed
fmt and clippy
1 parent 0bd5c99 commit 3660f9d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/windows/mod.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use windows::{
1313
Win32::System::SystemInformation::GetLogicalProcessorInformation,
1414
Win32::System::SystemInformation::GetTickCount64,
1515
Win32::System::SystemInformation::GlobalMemoryStatusEx,
16-
Win32::System::SystemInformation::MEMORYSTATUSEX,
1716
Win32::System::SystemInformation::RelationProcessorCore,
17+
Win32::System::SystemInformation::MEMORYSTATUSEX,
1818
Win32::System::WindowsProgramming::GetUserNameA,
1919
};
2020

@@ -302,7 +302,7 @@ impl GeneralReadout for WindowsGeneralReadout {
302302
struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION {
303303
mask: usize,
304304
relationship: u32,
305-
_unused: [u64; 2]
305+
_unused: [u64; 2],
306306
}
307307

308308
// The required size of the buffer, in bytes
@@ -318,7 +318,7 @@ impl GeneralReadout for WindowsGeneralReadout {
318318
// Could be 0, or some other bogus size
319319
if needed_size == 0 || needed_size < struct_size || needed_size % struct_size != 0 {
320320
return Err(ReadoutError::Other(
321-
"Call to \"GetLogicalProcessorInformation\" returned an invalid size.".to_string()
321+
"Call to \"GetLogicalProcessorInformation\" returned an invalid size.".to_string(),
322322
));
323323
}
324324

@@ -335,9 +335,9 @@ impl GeneralReadout for WindowsGeneralReadout {
335335
}
336336

337337
// If failed for some reason
338-
if result.as_bool() == false {
338+
if !result.as_bool() {
339339
return Err(ReadoutError::Other(
340-
"Call to \"GetLogicalProcessorInformation\" failed.".to_string()
340+
"Call to \"GetLogicalProcessorInformation\" failed.".to_string(),
341341
))?;
342342
}
343343

@@ -348,14 +348,15 @@ impl GeneralReadout for WindowsGeneralReadout {
348348
buf.set_len(count as usize);
349349
}
350350

351-
let phys_proc_count = buf.iter()
351+
let phys_proc_count = buf
352+
.iter()
352353
// Only interested in processor packages (physical processors.)
353354
.filter(|proc_info| proc_info.Relationship == RelationProcessorCore)
354355
.count();
355356

356-
return if phys_proc_count == 0 {
357+
if phys_proc_count == 0 {
357358
Err(ReadoutError::Other(
358-
"No physical processor cores found.".to_string()
359+
"No physical processor cores found.".to_string(),
359360
))?
360361
} else {
361362
Ok(phys_proc_count)
@@ -364,7 +365,8 @@ impl GeneralReadout for WindowsGeneralReadout {
364365

365366
fn cpu_cores(&self) -> Result<usize, ReadoutError> {
366367
// Open the registry key containing the CPUs information.
367-
let cpu_info = RegKey::predef(HKEY_LOCAL_MACHINE).open_subkey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor")?;
368+
let cpu_info = RegKey::predef(HKEY_LOCAL_MACHINE)
369+
.open_subkey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor")?;
368370
// Count the number of subkeys, which is the number of CPU logical processors.
369371
Ok(cpu_info.enum_keys().count())
370372
}

0 commit comments

Comments
 (0)