File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 1212//! 5) the VMM registers the new device onto corresponding device managers according the allocated
1313//! resources.
1414
15+ use std:: ops:: Deref ;
1516use std:: { u16, u32, u64} ;
1617
1718/// Enumeration describing a device's resource constraints.
@@ -245,6 +246,14 @@ impl DeviceResources {
245246 }
246247}
247248
249+ impl Deref for DeviceResources {
250+ type Target = Vec < Resource > ;
251+
252+ fn deref ( & self ) -> & Self :: Target {
253+ & self . 0
254+ }
255+ }
256+
248257#[ cfg( test) ]
249258mod tests {
250259 use super :: * ;
@@ -431,4 +440,14 @@ mod tests {
431440 panic ! ( "KVM slot resource constraint is invalid." ) ;
432441 }
433442 }
443+
444+ #[ test]
445+ fn test_resources_deref ( ) {
446+ let resources = get_device_resource ( ) ;
447+ let mut count = 0 ;
448+ for _res in resources. iter ( ) {
449+ count += 1 ;
450+ }
451+ assert_eq ! ( count, resources. 0 . len( ) ) ;
452+ }
434453}
You can’t perform that action at this time.
0 commit comments