@@ -373,7 +373,7 @@ impl ComponentInner {
373
373
}
374
374
}
375
375
376
- fn read_temp_dir < F : FnMut ( PathBuf ) > ( path : & str , starts_with : & str , mut f : F ) {
376
+ fn read_temp_dir < F : FnMut ( PathBuf ) > ( path : & Path , starts_with : & str , mut f : F ) {
377
377
if let Ok ( dir) = read_dir ( path) {
378
378
for entry in dir. flatten ( ) {
379
379
if !entry
@@ -420,18 +420,16 @@ impl ComponentsInner {
420
420
}
421
421
422
422
pub ( crate ) fn refresh ( & mut self ) {
423
- self . refresh_from_sys_class_path ( "/sys/class" ) ;
423
+ self . refresh_from_sys_class_path ( Path :: new ( "/sys/class" ) ) ;
424
424
}
425
425
426
- fn refresh_from_sys_class_path ( & mut self , path : & str ) {
427
- let hwmon_path = format ! ( "{path}/hwmon" ) ;
428
- read_temp_dir ( & hwmon_path, "hwmon" , |path| {
426
+ fn refresh_from_sys_class_path ( & mut self , path : & Path ) {
427
+ read_temp_dir ( & path. join ( "hwmon" ) , "hwmon" , |path| {
429
428
ComponentInner :: from_hwmon ( & mut self . components , & path) ;
430
429
} ) ;
431
430
if self . components . is_empty ( ) {
432
431
// Normally should only be used by raspberry pi.
433
- let thermal_path = format ! ( "{path}/thermal" ) ;
434
- read_temp_dir ( & thermal_path, "thermal_" , |path| {
432
+ read_temp_dir ( & path. join ( "thermal" ) , "thermal_" , |path| {
435
433
let temp = path. join ( "temp" ) ;
436
434
if temp. exists ( ) {
437
435
let Some ( name) = get_file_line ( & path. join ( "type" ) , 16 ) else {
@@ -468,12 +466,7 @@ mod tests {
468
466
. expect ( "failed to write to temp1_input file" ) ;
469
467
470
468
let mut components = ComponentsInner :: new ( ) ;
471
- components. refresh_from_sys_class_path (
472
- temp_dir
473
- . path ( )
474
- . to_str ( )
475
- . expect ( "failed to convert path to string" ) ,
476
- ) ;
469
+ components. refresh_from_sys_class_path ( temp_dir. path ( ) ) ;
477
470
let components = components. into_vec ( ) ;
478
471
479
472
assert_eq ! ( components. len( ) , 1 ) ;
@@ -502,12 +495,7 @@ mod tests {
502
495
fs:: write ( hwmon0_dir. join ( "temp1_crit" ) , "100" ) . expect ( "failed to write to temp1_min file" ) ;
503
496
504
497
let mut components = ComponentsInner :: new ( ) ;
505
- components. refresh_from_sys_class_path (
506
- temp_dir
507
- . path ( )
508
- . to_str ( )
509
- . expect ( "failed to convert path to string" ) ,
510
- ) ;
498
+ components. refresh_from_sys_class_path ( temp_dir. path ( ) ) ;
511
499
let components = components. into_vec ( ) ;
512
500
513
501
assert_eq ! ( components. len( ) , 1 ) ;
@@ -539,12 +527,7 @@ mod tests {
539
527
fs:: write ( hwmon0_dir. join ( "temp2_crit" ) , "200" ) . expect ( "failed to write to temp2_min file" ) ;
540
528
541
529
let mut components = ComponentsInner :: new ( ) ;
542
- components. refresh_from_sys_class_path (
543
- temp_dir
544
- . path ( )
545
- . to_str ( )
546
- . expect ( "failed to convert path to string" ) ,
547
- ) ;
530
+ components. refresh_from_sys_class_path ( temp_dir. path ( ) ) ;
548
531
let mut components = components. into_vec ( ) ;
549
532
components. sort_by_key ( |c| c. inner . label . clone ( ) ) ;
550
533
@@ -588,12 +571,7 @@ mod tests {
588
571
fs:: write ( hwmon0_dir. join ( "temp2_crit" ) , "200" ) . expect ( "failed to write to temp2_min file" ) ;
589
572
590
573
let mut components = ComponentsInner :: new ( ) ;
591
- components. refresh_from_sys_class_path (
592
- temp_dir
593
- . path ( )
594
- . to_str ( )
595
- . expect ( "failed to convert path to string" ) ,
596
- ) ;
574
+ components. refresh_from_sys_class_path ( temp_dir. path ( ) ) ;
597
575
let mut components = components. into_vec ( ) ;
598
576
components. sort_by_key ( |c| c. inner . label . clone ( ) ) ;
599
577
0 commit comments