File tree 2 files changed +16
-11
lines changed
2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
81
81
(#[ 1642] ( https://github.com/nix-rust/nix/pull/1642 ) )
82
82
- Fixed a panic in ` LinkAddr::addr ` . That function now returns an ` Option ` .
83
83
(#[ 1675] ( https://github.com/nix-rust/nix/pull/1675 ) )
84
+ (#[ 1677] ( https://github.com/nix-rust/nix/pull/1677 ) )
84
85
85
86
### Removed
86
87
Original file line number Diff line number Diff line change @@ -1351,28 +1351,32 @@ mod datalink {
1351
1351
}
1352
1352
1353
1353
/// Physical-layer address (MAC)
1354
- pub fn addr( & self ) -> [ u8 ; 6 ] {
1355
- [
1354
+ // Returns an Option just for cross-platform compatibility
1355
+ pub fn addr( & self ) -> Option <[ u8 ; 6 ] > {
1356
+ Some ( [
1356
1357
self . 0 . sll_addr[ 0 ] as u8 ,
1357
1358
self . 0 . sll_addr[ 1 ] as u8 ,
1358
1359
self . 0 . sll_addr[ 2 ] as u8 ,
1359
1360
self . 0 . sll_addr[ 3 ] as u8 ,
1360
1361
self . 0 . sll_addr[ 4 ] as u8 ,
1361
1362
self . 0 . sll_addr[ 5 ] as u8 ,
1362
- ]
1363
+ ] )
1363
1364
}
1364
1365
}
1365
1366
1366
1367
impl fmt:: Display for LinkAddr {
1367
1368
fn fmt( & self , f: & mut fmt:: Formatter ) -> fmt:: Result {
1368
- let addr = self . addr( ) ;
1369
- write!( f, "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}" ,
1370
- addr[ 0 ] ,
1371
- addr[ 1 ] ,
1372
- addr[ 2 ] ,
1373
- addr[ 3 ] ,
1374
- addr[ 4 ] ,
1375
- addr[ 5 ] )
1369
+ if let Some ( addr) = self . addr( ) {
1370
+ write!( f, "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}" ,
1371
+ addr[ 0 ] ,
1372
+ addr[ 1 ] ,
1373
+ addr[ 2 ] ,
1374
+ addr[ 3 ] ,
1375
+ addr[ 4 ] ,
1376
+ addr[ 5 ] )
1377
+ } else {
1378
+ Ok ( ( ) )
1379
+ }
1376
1380
}
1377
1381
}
1378
1382
}
You can’t perform that action at this time.
0 commit comments