Skip to content

Commit 01a3c22

Browse files
committed
Transition to Rust 2018
Signed-off-by: Levente Kurusa <[email protected]>
1 parent b5e0706 commit 01a3c22

18 files changed

+97
-97
lines changed

src/blkio.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use std::fs::File;
66
use std::io::{Read, Write};
77
use std::path::PathBuf;
88

9-
use error::*;
10-
use error::ErrorKind::*;
9+
use crate::error::*;
10+
use crate::error::ErrorKind::*;
1111

12-
use {
12+
use crate::{
1313
BlkIoResources, ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem,
1414
};
1515

@@ -48,7 +48,7 @@ pub struct IoService {
4848
/// How many items were synchronously transferred.
4949
pub sync: u64,
5050
/// How many items were asynchronously transferred.
51-
pub async: u64,
51+
pub r#async: u64,
5252
/// Total number of items transferred.
5353
pub total: u64,
5454
}
@@ -77,7 +77,7 @@ fn parse_io_service(s: String) -> Result<Vec<IoService>> {
7777
read: read_val.parse::<u64>().unwrap(),
7878
write: write_val.parse::<u64>().unwrap(),
7979
sync: sync_val.parse::<u64>().unwrap(),
80-
async: async_val.parse::<u64>().unwrap(),
80+
r#async: async_val.parse::<u64>().unwrap(),
8181
total: total_val.parse::<u64>().unwrap(),
8282
}),
8383
_ => None,
@@ -695,9 +695,9 @@ impl BlkIoController {
695695

696696
#[cfg(test)]
697697
mod test {
698-
use blkio::{parse_blkio_data, BlkIoData};
699-
use blkio::{parse_io_service, parse_io_service_total, IoService};
700-
use error::*;
698+
use crate::blkio::{parse_blkio_data, BlkIoData};
699+
use crate::blkio::{parse_io_service, parse_io_service_total, IoService};
700+
use crate::error::*;
701701

702702
static TEST_VALUE: &str = "\
703703
8:32 Read 4280320
@@ -773,7 +773,7 @@ Total 61823067136
773773
read: 4280320,
774774
write: 0,
775775
sync: 4280320,
776-
async: 0,
776+
r#async: 0,
777777
total: 4280320,
778778
},
779779
IoService {
@@ -782,7 +782,7 @@ Total 61823067136
782782
read: 5705479168,
783783
write: 56096055296,
784784
sync: 11213923328,
785-
async: 50587611136,
785+
r#async: 50587611136,
786786
total: 61801534464,
787787
},
788788
IoService {
@@ -791,7 +791,7 @@ Total 61823067136
791791
read: 10059776,
792792
write: 0,
793793
sync: 10059776,
794-
async: 0,
794+
r#async: 0,
795795
total: 10059776,
796796
},
797797
IoService {
@@ -800,7 +800,7 @@ Total 61823067136
800800
read: 7192576,
801801
write: 0,
802802
sync: 7192576,
803-
async: 0,
803+
r#async: 0,
804804
total: 7192576,
805805
}
806806
]

src/cgroup.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! This module handles cgroup operations. Start here!
22
3-
use error::*;
3+
use crate::error::*;
44

5-
use {CgroupPid, ControllIdentifier, Controller, Hierarchy, Resources, Subsystem};
5+
use crate::{CgroupPid, ControllIdentifier, Controller, Hierarchy, Resources, Subsystem};
66

77
use std::convert::From;
88
use std::path::Path;

src/cgroup_builder.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
//! .done()
5454
//! .build();
5555
//! ```
56-
use error::*;
56+
use crate::error::*;
5757

58-
use {pid, BlkIoDeviceResource, BlkIoDeviceThrottleResource, Cgroup, DeviceResource, Hierarchy, HugePageResource, NetworkPriority, Resources};
58+
use crate::{pid, BlkIoDeviceResource, BlkIoDeviceThrottleResource, Cgroup, DeviceResource, Hierarchy, HugePageResource, NetworkPriority, Resources};
5959

6060
macro_rules! gen_setter {
6161
($res:ident, $cont:ident, $func:ident, $name:ident, $ty:ty) => {
@@ -215,9 +215,9 @@ impl<'a> DeviceResourceBuilder<'a> {
215215
pub fn device(mut self,
216216
major: i64,
217217
minor: i64,
218-
devtype: ::devices::DeviceType,
218+
devtype: crate::devices::DeviceType,
219219
allow: bool,
220-
access: Vec<::devices::DevicePermissions>)
220+
access: Vec<crate::devices::DevicePermissions>)
221221
-> DeviceResourceBuilder<'a> {
222222
self.cgroup.resources.devices.update_values = true;
223223
self.cgroup.resources.devices.devices.push(DeviceResource {

src/cpu.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use std::fs::File;
77
use std::io::{Read, Write};
88
use std::path::PathBuf;
99

10-
use error::*;
11-
use error::ErrorKind::*;
10+
use crate::error::*;
11+
use crate::error::ErrorKind::*;
1212

13-
use {
13+
use crate::{
1414
ControllIdentifier, ControllerInternal, Controllers, CpuResources, Resources, Subsystem,
1515
};
1616

src/cpuacct.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use std::fs::File;
66
use std::io::{Read, Write};
77
use std::path::PathBuf;
88

9-
use error::*;
10-
use error::ErrorKind::*;
9+
use crate::error::*;
10+
use crate::error::ErrorKind::*;
1111

12-
use {ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
12+
use crate::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
1313

1414
/// A controller that allows controlling the `cpuacct` subsystem of a Cgroup.
1515
///

src/cpuset.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use std::fs::File;
66
use std::io::{Read, Write};
77
use std::path::PathBuf;
88

9-
use error::*;
10-
use error::ErrorKind::*;
9+
use crate::error::*;
10+
use crate::error::ErrorKind::*;
1111

12-
use {
12+
use crate::{
1313
ControllIdentifier, ControllerInternal, Controllers, CpuResources, Resources, Subsystem,
1414
};
1515

@@ -427,7 +427,7 @@ impl CpuSetController {
427427

428428
#[cfg(test)]
429429
mod tests {
430-
use cpuset;
430+
use crate::cpuset;
431431
#[test]
432432
fn test_parse_range() {
433433
let test_cases = vec![

src/devices.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
use std::io::{Read, Write};
66
use std::path::PathBuf;
77

8-
use error::*;
9-
use error::ErrorKind::*;
8+
use crate::error::*;
9+
use crate::error::ErrorKind::*;
1010

11-
use {
11+
use crate::{
1212
ControllIdentifier, ControllerInternal, Controllers, DeviceResource, DeviceResources,
1313
Resources, Subsystem,
1414
};

src/freezer.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
use std::io::{Read, Write};
66
use std::path::PathBuf;
77

8-
use error::*;
9-
use error::ErrorKind::*;
8+
use crate::error::*;
9+
use crate::error::ErrorKind::*;
1010

11-
use {ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
11+
use crate::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
1212

1313
/// A controller that allows controlling the `freezer` subsystem of a Cgroup.
1414
///

src/hierarchies.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ use std::io::BufRead;
88
use std::io::BufReader;
99
use std::path::{Path, PathBuf};
1010

11-
use blkio::BlkIoController;
12-
use cpu::CpuController;
13-
use cpuacct::CpuAcctController;
14-
use cpuset::CpuSetController;
15-
use devices::DevicesController;
16-
use freezer::FreezerController;
17-
use hugetlb::HugeTlbController;
18-
use memory::MemController;
19-
use net_cls::NetClsController;
20-
use net_prio::NetPrioController;
21-
use perf_event::PerfEventController;
22-
use pid::PidController;
23-
use rdma::RdmaController;
24-
use {Controllers, Hierarchy, Subsystem};
11+
use crate::blkio::BlkIoController;
12+
use crate::cpu::CpuController;
13+
use crate::cpuacct::CpuAcctController;
14+
use crate::cpuset::CpuSetController;
15+
use crate::devices::DevicesController;
16+
use crate::freezer::FreezerController;
17+
use crate::hugetlb::HugeTlbController;
18+
use crate::memory::MemController;
19+
use crate::net_cls::NetClsController;
20+
use crate::net_prio::NetPrioController;
21+
use crate::perf_event::PerfEventController;
22+
use crate::pid::PidController;
23+
use crate::rdma::RdmaController;
24+
use crate::{Controllers, Hierarchy, Subsystem};
2525

26-
use cgroup::Cgroup;
26+
use crate::cgroup::Cgroup;
2727

2828
/// The standard, original cgroup implementation. Often referred to as "cgroupv1".
2929
pub struct V1 {

src/hugetlb.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use std::fs::File;
66
use std::io::{Read, Write};
77
use std::path::PathBuf;
88

9-
use error::*;
10-
use error::ErrorKind::*;
9+
use crate::error::*;
10+
use crate::error::ErrorKind::*;
1111

12-
use {
12+
use crate::{
1313
ControllIdentifier, ControllerInternal, Controllers, HugePageResources, Resources,
1414
Subsystem,
1515
};

src/lib.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ pub mod pid;
2323
pub mod rdma;
2424
pub mod cgroup_builder;
2525

26-
use blkio::BlkIoController;
27-
use cpu::CpuController;
28-
use cpuacct::CpuAcctController;
29-
use cpuset::CpuSetController;
30-
use devices::DevicesController;
31-
use error::*;
32-
use freezer::FreezerController;
33-
use hugetlb::HugeTlbController;
34-
use memory::MemController;
35-
use net_cls::NetClsController;
36-
use net_prio::NetPrioController;
37-
use perf_event::PerfEventController;
38-
use pid::PidController;
39-
use rdma::RdmaController;
40-
41-
pub use cgroup::Cgroup;
26+
use crate::blkio::BlkIoController;
27+
use crate::cpu::CpuController;
28+
use crate::cpuacct::CpuAcctController;
29+
use crate::cpuset::CpuSetController;
30+
use crate::devices::DevicesController;
31+
use crate::error::*;
32+
use crate::freezer::FreezerController;
33+
use crate::hugetlb::HugeTlbController;
34+
use crate::memory::MemController;
35+
use crate::net_cls::NetClsController;
36+
use crate::net_prio::NetPrioController;
37+
use crate::perf_event::PerfEventController;
38+
use crate::pid::PidController;
39+
use crate::rdma::RdmaController;
40+
41+
pub use crate::cgroup::Cgroup;
4242

4343
/// Contains all the subsystems that are available in this crate.
4444
#[derive(Debug)]
@@ -160,7 +160,7 @@ mod sealed {
160160
}
161161
}
162162

163-
pub(crate) use sealed::ControllerInternal;
163+
pub(crate) use crate::sealed::ControllerInternal;
164164

165165
/// A Controller is a subsystem attached to the control group.
166166
///
@@ -347,13 +347,13 @@ pub struct DeviceResource {
347347
/// If true, access to the device is allowed, otherwise it's denied.
348348
pub allow: bool,
349349
/// `'c'` for character device, `'b'` for block device; or `'a'` for all devices.
350-
pub devtype: ::devices::DeviceType,
350+
pub devtype: crate::devices::DeviceType,
351351
/// The major number of the device.
352352
pub major: i64,
353353
/// The minor number of the device.
354354
pub minor: i64,
355355
/// Sequence of `'r'`, `'w'` or `'m'`, each denoting read, write or mknod permissions.
356-
pub access: Vec<::devices::DevicePermissions>,
356+
pub access: Vec<crate::devices::DevicePermissions>,
357357
}
358358

359359
/// Limit the usage of devices for the control group's tasks.

src/memory.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use std::fs::File;
66
use std::io::{Read, Write};
77
use std::path::PathBuf;
88

9-
use error::*;
10-
use error::ErrorKind::*;
9+
use crate::error::*;
10+
use crate::error::ErrorKind::*;
1111

12-
use {
12+
use crate::{
1313
ControllIdentifier, ControllerInternal, Controllers, MemoryResources, Resources, Subsystem,
1414
};
1515

@@ -85,7 +85,7 @@ pub struct NumaStat {
8585

8686
fn parse_numa_stat(s: String) -> Result<NumaStat> {
8787
// Parse the number of nodes
88-
let nodes = (s.split_whitespace().collect::<Vec<_>>().len() - 8) / 8;
88+
let _nodes = (s.split_whitespace().collect::<Vec<_>>().len() - 8) / 8;
8989
let mut ls = s.lines();
9090
let total_line = ls.next().unwrap();
9191
let file_line = ls.next().unwrap();
@@ -697,7 +697,7 @@ fn read_string_from(mut file: File) -> Result<String> {
697697

698698
#[cfg(test)]
699699
mod tests {
700-
use memory::{
700+
use crate::memory::{
701701
parse_memory_stat, parse_numa_stat, parse_oom_control, MemoryStat, NumaStat, OomControl,
702702
};
703703

src/net_cls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use std::fs::File;
66
use std::io::{Read, Write};
77
use std::path::PathBuf;
88

9-
use error::*;
10-
use error::ErrorKind::*;
9+
use crate::error::*;
10+
use crate::error::ErrorKind::*;
1111

12-
use {
12+
use crate::{
1313
ControllIdentifier, ControllerInternal, Controllers, NetworkResources, Resources,
1414
Subsystem,
1515
};

src/net_prio.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use std::fs::File;
77
use std::io::{BufRead, BufReader, Read, Write};
88
use std::path::PathBuf;
99

10-
use error::*;
11-
use error::ErrorKind::*;
10+
use crate::error::*;
11+
use crate::error::ErrorKind::*;
1212

13-
use {
13+
use crate::{
1414
ControllIdentifier, ControllerInternal, Controllers, NetworkResources, Resources,
1515
Subsystem,
1616
};

src/perf_event.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
//! [tools/perf/Documentation/perf-record.txt](https://raw.githubusercontent.com/torvalds/linux/master/tools/perf/Documentation/perf-record.txt)
55
use std::path::PathBuf;
66

7-
use error::*;
7+
use crate::error::*;
88

9-
use {ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
9+
use crate::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
1010

1111
/// A controller that allows controlling the `perf_event` subsystem of a Cgroup.
1212
///

src/pid.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use std::fs::File;
66
use std::io::{Read, Write};
77
use std::path::PathBuf;
88

9-
use error::*;
10-
use error::ErrorKind::*;
9+
use crate::error::*;
10+
use crate::error::ErrorKind::*;
1111

12-
use {
12+
use crate::{
1313
ControllIdentifier, ControllerInternal, Controllers, PidResources, Resources, Subsystem,
1414
};
1515

0 commit comments

Comments
 (0)