Repository: GuillaumeGomez/sysinfo
Pull request #1103 (2023-10-16 22:18:20)

Remove `sort_by` methods and rename getters into `list` and `list_mut`
Part of https://github.com/GuillaumeGomez/sysinfo/issues/1080.


Patch:
diff --git a/README.md b/README.md
index 815a88b..24bcc60 100644
--- a/README.md
+++ b/README.md
@@ -72,7 +72,7 @@ println!("=> disks:");
 let mut disks = Disks::new();
 // We refresh the disk list.
 disks.refresh_list();
-for disk in disks.iter() {
+for disk in &disks {
     println!("{disk:?}");
 }
 
@@ -90,7 +90,7 @@ let mut components = Components::new();
 // We refresh the component list.
 components.refresh_list();
 println!("=> components:");
-for component in components.iter() {
+for component in &components {
     println!("{component:?}");
 }
 ```
diff --git a/benches/basic.rs b/benches/basic.rs
index 784aebe..e2dba98 100644
--- a/benches/basic.rs
+++ b/benches/basic.rs
@@ -72,7 +72,7 @@ fn bench_refresh_disk(b: &mut test::Bencher) {
     let mut disks = sysinfo::Disks::new();
     disks.refresh_list();
 
-    let disks = disks.disks_mut();
+    let disks = disks.list_mut();
     let disk = &mut disks[0];
     b.iter(move || {
         disk.refresh();
diff --git a/examples/simple.rs b/examples/simple.rs
index d60edbd..e79324e 100644
--- a/examples/simple.rs
+++ b/examples/simple.rs
@@ -362,12 +362,12 @@ fn interpret_input(
             }
         }
         "disks" => {
-            for disk in disks.disks() {
+            for disk in disks {
                 writeln!(&mut io::stdout(), "{disk:?}");
             }
         }
         "users" => {
-            for user in users.users() {
+            for user in users {
                 writeln!(
                     &mut io::stdout(),
                     "{:?} => {:?}",
diff --git a/src/common.rs b/src/common.rs
index f812d33..f348527 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -1872,7 +1872,7 @@ impl NetworkData {
 ///
 /// let mut disks = Disks::new();
 /// disks.refresh_list();
-/// for disk in disks.disks() {
+/// for disk in disks.list() {
 ///     println!("{:?}: {:?}", disk.name(), disk.kind());
 /// }
 /// ```
@@ -1888,7 +1888,7 @@ impl Disk {
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
-    /// for disk in disks.disks() {
+    /// for disk in disks.list() {
     ///     println!("[{:?}] {:?}", disk.name(), disk.kind());
     /// }
     /// ```
@@ -1903,7 +1903,7 @@ impl Disk {
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
-    /// for disk in disks.disks() {
+    /// for disk in disks.list() {
     ///     println!("{:?}", disk.name());
     /// }
     /// ```
@@ -1918,7 +1918,7 @@ impl Disk {
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
-    /// for disk in disks.disks() {
+    /// for disk in disks.list() {
     ///     println!("[{:?}] {:?}", disk.name(), disk.file_system());
     /// }
     /// ```
@@ -1933,7 +1933,7 @@ impl Disk {
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
-    /// for disk in disks.disks() {
+    /// for disk in disks.list() {
     ///     println!("[{:?}] {:?}", disk.name(), disk.mount_point());
     /// }
     /// ```
@@ -1948,7 +1948,7 @@ impl Disk {
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
-    /// for disk in disks.disks() {
+    /// for disk in disks.list() {
     ///     println!("[{:?}] {}B", disk.name(), disk.total_space());
     /// }
     /// ```
@@ -1963,7 +1963,7 @@ impl Disk {
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
-    /// for disk in disks.disks() {
+    /// for disk in disks.list() {
     ///     println!("[{:?}] {}B", disk.name(), disk.available_space());
     /// }
     /// ```
@@ -1978,7 +1978,7 @@ impl Disk {
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
-    /// for disk in disks.disks() {
+    /// for disk in disks.list() {
     ///     println!("[{:?}] {}", disk.name(), disk.is_removable());
     /// }
     /// ```
@@ -1993,7 +1993,7 @@ impl Disk {
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
-    /// for disk in disks.disks_mut() {
+    /// for disk in disks.list_mut() {
     ///     disk.refresh();
     /// }
     /// ```
@@ -2009,7 +2009,7 @@ impl Disk {
 ///
 /// let mut disks = Disks::new();
 /// disks.refresh_list();
-/// for disk in disks.disks() {
+/// for disk in disks.list() {
 ///     println!("{disk:?}");
 /// }
 /// ```
@@ -2028,7 +2028,7 @@ impl<'a> IntoIterator for &'a Disks {
     type IntoIter = std::slice::Iter<'a, Disk>;
 
     fn into_iter(self) -> Self::IntoIter {
-        self.disks().iter()
+        self.list().iter()
     }
 }
 
@@ -2037,7 +2037,7 @@ impl<'a> IntoIterator for &'a mut Disks {
     type IntoIter = std::slice::IterMut<'a, Disk>;
 
     fn into_iter(self) -> Self::IntoIter {
-        self.disks_mut().iter_mut()
+        self.list_mut().iter_mut()
     }
 }
 
@@ -2049,7 +2049,7 @@ impl Disks {
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
-    /// for disk in disks.disks() {
+    /// for disk in disks.list() {
     ///     eprintln!("{disk:?}");
     /// }
     /// ```
@@ -2066,12 +2066,12 @@ impl Disks {
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
-    /// for disk in disks.disks() {
+    /// for disk in disks.list() {
     ///     eprintln!("{disk:?}");
     /// }
     /// ```
-    pub fn disks(&self) -> &[Disk] {
-        self.inner.disks()
+    pub fn list(&self) -> &[Disk] {
+        self.inner.list()
     }
 
     /// Returns the disks list.
@@ -2081,39 +2081,13 @@ impl Disks {
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
-    /// for disk in disks.disks_mut() {
+    /// for disk in disks.list_mut() {
     ///     disk.refresh();
     ///     eprintln!("{disk:?}");
     /// }
     /// ```
-    pub fn disks_mut(&mut self) -> &mut [Disk] {
-        self.inner.disks_mut()
-    }
-
-    /// Sort the disk list with the provided callback.
-    ///
-    /// Internally, it is using the [`slice::sort_unstable_by`] function, so please refer to it
-    /// for implementation details.
-    ///
-    /// You can do the same without this method by calling:
-    ///
-    /// ```no_run
-    /// use sysinfo::Disks;
-    ///
-    /// let mut disks = Disks::new();
-    /// disks.refresh_list();
-    /// disks.sort_by(|disk1, disk2| {
-    ///     disk1.name().partial_cmp(disk2.name()).unwrap()
-    /// });
-    /// ```
-    ///
-    /// ⚠️ If you use [`Disks::refresh_list`], you will need to call this method to sort the
-    /// disks again.
-    pub fn sort_by<F>(&mut self, compare: F)
-    where
-        F: FnMut(&Disk, &Disk) -> std::cmp::Ordering,
-    {
-        self.disks_mut().sort_unstable_by(compare);
+    pub fn list_mut(&mut self) -> &mut [Disk] {
+        self.inner.list_mut()
     }
 
     /// Refreshes the listed disks' information.
@@ -2134,7 +2108,7 @@ impl Disks {
     /// disks.refresh();
     /// ```
     pub fn refresh(&mut self) {
-        for disk in self.disks_mut() {
+        for disk in self.list_mut() {
             disk.refresh();
         }
     }
@@ -2166,13 +2140,13 @@ impl std::ops::Deref for Disks {
     type Target = [Disk];
 
     fn deref(&self) -> &Self::Target {
-        self.disks()
+        self.list()
     }
 }
 
 impl std::ops::DerefMut for Disks {
     fn deref_mut(&mut self) -> &mut Self::Target {
-        self.disks_mut()
+        self.list_mut()
     }
 }
 
@@ -2185,7 +2159,7 @@ impl std::ops::DerefMut for Disks {
 ///
 /// let mut disks = Disks::new();
 /// disks.refresh_list();
-/// for disk in disks.disks() {
+/// for disk in disks.list() {
 ///     println!("{:?}: {:?}", disk.name(), disk.kind());
 /// }
 /// ```
@@ -2205,7 +2179,7 @@ pub enum DiskKind {
 /// use sysinfo::Users;
 ///
 /// let mut users = Users::new();
-/// for user in users.users() {
+/// for user in users.list() {
 ///     println!("{} is in {} groups", user.name(), user.groups().len());
 /// }
 /// ```
@@ -2223,13 +2197,13 @@ impl std::ops::Deref for Users {
     type Target = [User];
 
     fn deref(&self) -> &Self::Target {
-        self.users()
+        self.list()
     }
 }
 
 impl std::ops::DerefMut for Users {
     fn deref_mut(&mut self) -> &mut Self::Target {
-        self.users_mut()
+        self.list_mut()
     }
 }
 
@@ -2238,7 +2212,7 @@ impl<'a> IntoIterator for &'a Users {
     type IntoIter = std::slice::Iter<'a, User>;
 
     fn into_iter(self) -> Self::IntoIter {
-        self.users().iter()
+        self.list().iter()
     }
 }
 
@@ -2247,7 +2221,7 @@ impl<'a> IntoIterator for &'a mut Users {
     type IntoIter = std::slice::IterMut<'a, User>;
 
     fn into_iter(self) -> Self::IntoIter {
-        self.users_mut().iter_mut()
+        self.list_mut().iter_mut()
     }
 }
 
@@ -2259,7 +2233,7 @@ impl Users {
     ///
     /// let mut users = Users::new();
     /// users.refresh_list();
-    /// for user in users.users() {
+    /// for user in users.list() {
     ///     eprintln!("{user:?}");
     /// }
     /// ```
@@ -2274,11 +2248,11 @@ impl Users {
     ///
     /// let mut users = Users::new();
     /// users.refresh_list();
-    /// for user in users.users() {
+    /// for user in users.list() {
     ///     eprintln!("{user:?}");
     /// }
     /// ```
-    pub fn users(&self) -> &[User] {
+    pub fn list(&self) -> &[User] {
         &self.users
     }
 
@@ -2289,40 +2263,14 @@ impl Users {
     ///
     /// let mut users = Users::new();
     /// users.refresh_list();
-    /// users.users_mut().sort_by(|user1, user2| {
+    /// users.list_mut().sort_by(|user1, user2| {
     ///     user1.name().partial_cmp(user2.name()).unwrap()
     /// });
     /// ```
-    pub fn users_mut(&mut self) -> &mut [User] {
+    pub fn list_mut(&mut self) -> &mut [User] {
         &mut self.users
     }
 
-    /// Sort the users list with the provided callback.
-    ///
-    /// Internally, it is using the [`slice::sort_unstable_by`] function, so please refer to it
-    /// for implementation details.
-    ///
-    /// You can do the same without this method by calling:
-    ///
-    /// ```no_run
-    /// use sysinfo::Users;
-    ///
-    /// let mut users = Users::new();
-    /// users.refresh_list();
-    /// users.sort_by(|user1, user2| {
-    ///     user1.name().partial_cmp(user2.name()).unwrap()
-    /// });
-    /// ```
-    ///
-    /// ⚠️ If you use [`Users::refresh_list`], you will need to call this method to sort the
-    /// users again.
-    pub fn sort_by<F>(&mut self, compare: F)
-    where
-        F: FnMut(&User, &User) -> std::cmp::Ordering,
-    {
-        self.users.sort_unstable_by(compare);
-    }
-
     /// The user list will be emptied then completely recomputed.
     ///
     /// ```no_run
@@ -2346,7 +2294,7 @@ impl Users {
     /// # use sysinfo::Users;
     /// let mut users = Users::new();
     /// users.refresh_list();
-    /// users.users().find(|user| user.id() == user_id);
+    /// users.list().find(|user| user.id() == user_id);
     /// ```
     ///
     /// Full example:
@@ -2611,7 +2559,7 @@ cfg_if::cfg_if! {
 ///
 /// let mut users = Users::new();
 /// users.refresh_list();
-/// for user in users.users() {
+/// for user in users.list() {
 ///     println!("{:?}", user);
 /// }
 /// ```
@@ -2649,7 +2597,7 @@ impl User {
     ///
     /// let mut users = Users::new();
     /// users.refresh_list();
-    /// for user in users.users() {
+    /// for user in users.list() {
     ///     println!("{:?}", *user.id());
     /// }
     /// ```
@@ -2671,7 +2619,7 @@ impl User {
     ///
     /// let mut users = Users::new();
     /// users.refresh_list();
-    /// for user in users.users() {
+    /// for user in users.list() {
     ///     println!("{}", *user.group_id());
     /// }
     /// ```
@@ -2686,7 +2634,7 @@ impl User {
     ///
     /// let mut users = Users::new();
     /// users.refresh_list();
-    /// for user in users.users() {
+    /// for user in users.list() {
     ///     println!("{}", user.name());
     /// }
     /// ```
@@ -2703,7 +2651,7 @@ impl User {
     ///
     /// let mut users = Users::new();
     /// users.refresh_list();
-    /// for user in users.users() {
+    /// for user in users.list() {
     ///     println!("{} is in {:?}", user.name(), user.groups());
     /// }
     /// ```
@@ -2721,7 +2669,7 @@ impl User {
 ///
 /// let mut users = Users::new();
 ///
-/// for user in users.users() {
+/// for user in users.list() {
 ///     println!(
 ///         "user: (ID: {:?}, group ID: {:?}, name: {:?})",
 ///         user.id(),
@@ -2749,7 +2697,7 @@ impl Group {
     ///
     /// let mut users = Users::new();
     ///
-    /// for user in users.users() {
+    /// for user in users.list() {
     ///     for group in user.groups() {
     ///         println!("{:?}", group.id());
     ///     }
@@ -2766,7 +2714,7 @@ impl Group {
     ///
     /// let mut users = Users::new();
     ///
-    /// for user in users.users() {
+    /// for user in users.list() {
     ///     for group in user.groups() {
     ///         println!("{}", group.name());
     ///     }
@@ -3028,13 +2976,13 @@ impl std::ops::Deref for Components {
     type Target = [Component];
 
     fn deref(&self) -> &Self::Target {
-        self.components()
+        self.list()
     }
 }
 
 impl std::ops::DerefMut for Components {
     fn deref_mut(&mut self) -> &mut Self::Target {
-        self.components_mut()
+        self.list_mut()
     }
 }
 
@@ -3043,7 +2991,7 @@ impl<'a> IntoIterator for &'a Components {
     type IntoIter = std::slice::Iter<'a, Component>;
 
     fn into_iter(self) -> Self::IntoIter {
-        self.components().iter()
+        self.list().iter()
     }
 }
 
@@ -3052,7 +3000,7 @@ impl<'a> IntoIterator for &'a mut Components {
     type IntoIter = std::slice::IterMut<'a, Component>;
 
     fn into_iter(self) -> Self::IntoIter {
-        self.components_mut().iter_mut()
+        self.list_mut().iter_mut()
     }
 }
 
@@ -3081,12 +3029,12 @@ impl Components {
     ///
     /// let mut components = Components::new();
     /// components.refresh_list();
-    /// for component in components.components() {
+    /// for component in components.list() {
     ///     eprintln!("{component:?}");
     /// }
     /// ```
-    pub fn components(&self) -> &[Component] {
-        self.inner.components()
+    pub fn list(&self) -> &[Component] {
+        self.inner.list()
     }
 
     /// Returns the components list.
@@ -3096,39 +3044,13 @@ impl Components {
     ///
     /// let mut components = Components::new();
     /// components.refresh_list();
-    /// for component in components.components_mut() {
+    /// for component in components.list_mut() {
     ///     component.refresh();
     ///     eprintln!("{component:?}");
     /// }
     /// ```
-    pub fn components_mut(&mut self) -> &mut [Component] {
-        self.inner.components_mut()
-    }
-
-    /// Sort the components list with the provided callback.
-    ///
-    /// Internally, it is using the [`slice::sort_unstable_by`] function, so please refer to it
-    /// for implementation details.
-    ///
-    /// You can do the same without this method by calling:
-    ///
-    /// ```no_run
-    /// use sysinfo::Components;
-    ///
-    /// let mut components = Components::new();
-    /// components.refresh_list();
-    /// components.sort_by(|component1, component2| {
-    ///     component2.label().partial_cmp(component2.label()).unwrap()
-    /// });
-    /// ```
-    ///
-    /// ⚠️ If you use [`Components::refresh_list`], you will need to call this method to sort the
-    /// components again.
-    pub fn sort_by<F>(&mut self, compare: F)
-    where
-        F: FnMut(&Component, &Component) -> std::cmp::Ordering,
-    {
-        self.components_mut().sort_unstable_by(compare);
+    pub fn list_mut(&mut self) -> &mut [Component] {
+        self.inner.list_mut()
     }
 
     /// Refreshes the listed components' information.
@@ -3149,7 +3071,7 @@ impl Components {
     /// components.refresh();
     /// ```
     pub fn refresh(&mut self) {
-        for component in self.components_mut() {
+        for component in self.list_mut() {
             component.refresh();
         }
     }
diff --git a/src/lib.rs b/src/lib.rs
index 5cf209b..9a87eee 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -293,19 +293,19 @@ mod test {
     }
 
     #[test]
-    fn check_users() {
+    fn check_list() {
         let mut users = Users::new();
-        assert!(users.users().is_empty());
+        assert!(users.list().is_empty());
         users.refresh_list();
-        assert!(users.users().len() >= MIN_USERS);
+        assert!(users.list().len() >= MIN_USERS);
     }
 
     #[test]
     fn check_uid_gid() {
         let mut users = Users::new();
-        assert!(users.users().is_empty());
+        assert!(users.list().is_empty());
         users.refresh_list();
-        let user_list = users.users();
+        let user_list = users.list();
         assert!(user_list.len() >= MIN_USERS);
 
         if IS_SUPPORTED {
diff --git a/src/unix/apple/app_store/component.rs b/src/unix/apple/app_store/component.rs
index 5be9276..25320e1 100644
--- a/src/unix/apple/app_store/component.rs
+++ b/src/unix/apple/app_store/component.rs
@@ -35,11 +35,11 @@ impl ComponentsInner {
         }
     }
 
-    pub(crate) fn components(&self) -> &[Component] {
+    pub(crate) fn list(&self) -> &[Component] {
         &self.components
     }
 
-    pub(crate) fn components_mut(&mut self) -> &mut [Component] {
+    pub(crate) fn list_mut(&mut self) -> &mut [Component] {
         &mut self.components
     }
 
diff --git a/src/unix/apple/disk.rs b/src/unix/apple/disk.rs
index 309d935..2722a15 100644
--- a/src/unix/apple/disk.rs
+++ b/src/unix/apple/disk.rs
@@ -89,20 +89,20 @@ impl crate::DisksInner {
 
     pub(crate) fn refresh_list(&mut self) {
         unsafe {
-            get_disks(&mut self.disks);
+            get_list(&mut self.disks);
         }
     }
 
-    pub(crate) fn disks(&self) -> &[Disk] {
+    pub(crate) fn list(&self) -> &[Disk] {
         &self.disks
     }
 
-    pub(crate) fn disks_mut(&mut self) -> &mut [Disk] {
+    pub(crate) fn list_mut(&mut self) -> &mut [Disk] {
         &mut self.disks
     }
 }
 
-unsafe fn get_disks(container: &mut Vec<Disk>) {
+unsafe fn get_list(container: &mut Vec<Disk>) {
     container.clear();
 
     let raw_disks = {
diff --git a/src/unix/apple/macos/component/arm.rs b/src/unix/apple/macos/component/arm.rs
index e6634b4..b34f8dc 100644
--- a/src/unix/apple/macos/component/arm.rs
+++ b/src/unix/apple/macos/component/arm.rs
@@ -31,11 +31,11 @@ impl ComponentsInner {
         }
     }
 
-    pub(crate) fn components(&self) -> &[Component] {
+    pub(crate) fn list(&self) -> &[Component] {
         &self.components
     }
 
-    pub(crate) fn components_mut(&mut self) -> &mut [Component] {
+    pub(crate) fn list_mut(&mut self) -> &mut [Component] {
         &mut self.components
     }
 
diff --git a/src/unix/apple/macos/component/x86.rs b/src/unix/apple/macos/component/x86.rs
index a6dd97d..c94763c 100644
--- a/src/unix/apple/macos/component/x86.rs
+++ b/src/unix/apple/macos/component/x86.rs
@@ -58,11 +58,11 @@ impl ComponentsInner {
         }
     }
 
-    pub(crate) fn components(&self) -> &[Component] {
+    pub(crate) fn list(&self) -> &[Component] {
         &self.components
     }
 
-    pub(crate) fn components_mut(&mut self) -> &mut [Component] {
+    pub(crate) fn list_mut(&mut self) -> &mut [Component] {
         &mut self.components
     }
 
diff --git a/src/unix/freebsd/component.rs b/src/unix/freebsd/component.rs
index fb4722c..62e6323 100644
--- a/src/unix/freebsd/component.rs
+++ b/src/unix/freebsd/component.rs
@@ -63,11 +63,11 @@ impl ComponentsInner {
         }
     }
 
-    pub(crate) fn components(&self) -> &[Component] {
+    pub(crate) fn list(&self) -> &[Component] {
         &self.components
     }
 
-    pub(crate) fn components_mut(&mut self) -> &mut [Component] {
+    pub(crate) fn list_mut(&mut self) -> &mut [Component] {
         &mut self.components
     }
 
diff --git a/src/unix/freebsd/disk.rs b/src/unix/freebsd/disk.rs
index b570417..cacba4c 100644
--- a/src/unix/freebsd/disk.rs
+++ b/src/unix/freebsd/disk.rs
@@ -62,14 +62,14 @@ impl crate::DisksInner {
     }
 
     pub(crate) fn refresh_list(&mut self) {
-        unsafe { get_all_disks(&mut self.disks) }
+        unsafe { get_all_list(&mut self.disks) }
     }
 
-    pub(crate) fn disks(&self) -> &[Disk] {
+    pub(crate) fn list(&self) -> &[Disk] {
         &self.disks
     }
 
-    pub(crate) fn disks_mut(&mut self) -> &mut [Disk] {
+    pub(crate) fn list_mut(&mut self) -> &mut [Disk] {
         &mut self.disks
     }
 }
@@ -88,7 +88,7 @@ unsafe fn refresh_disk(disk: &mut DiskInner, vfs: &mut libc::statvfs) -> bool {
     true
 }
 
-pub unsafe fn get_all_disks(container: &mut Vec<Disk>) {
+pub unsafe fn get_all_list(container: &mut Vec<Disk>) {
     container.clear();
 
     let mut fs_infos: *mut libc::statfs = std::ptr::null_mut();
diff --git a/src/unix/linux/component.rs b/src/unix/linux/component.rs
index 91dca27..938ea59 100644
--- a/src/unix/linux/component.rs
+++ b/src/unix/linux/component.rs
@@ -342,11 +342,11 @@ impl ComponentsInner {
         }
     }
 
-    pub(crate) fn components(&self) -> &[Component] {
+    pub(crate) fn list(&self) -> &[Component] {
         &self.components
     }
 
-    pub(crate) fn components_mut(&mut self) -> &mut [Component] {
+    pub(crate) fn list_mut(&mut self) -> &mut [Component] {
         &mut self.components
     }
 
diff --git a/src/unix/linux/disk.rs b/src/unix/linux/disk.rs
index 463245f..f2f0f9a 100644
--- a/src/unix/linux/disk.rs
+++ b/src/unix/linux/disk.rs
@@ -78,17 +78,17 @@ impl crate::DisksInner {
     }
 
     pub(crate) fn refresh_list(&mut self) {
-        get_all_disks(
+        get_all_list(
             &mut self.disks,
             &get_all_data("/proc/mounts", 16_385).unwrap_or_default(),
         )
     }
 
-    pub(crate) fn disks(&self) -> &[Disk] {
+    pub(crate) fn list(&self) -> &[Disk] {
         &self.disks
     }
 
-    pub(crate) fn disks_mut(&mut self) -> &mut [Disk] {
+    pub(crate) fn list_mut(&mut self) -> &mut [Disk] {
         &mut self.disks
     }
 }
@@ -204,7 +204,7 @@ fn find_type_for_device_name(device_name: &OsStr) -> DiskKind {
     }
 }
 
-fn get_all_disks(container: &mut Vec<Disk>, content: &str) {
+fn get_all_list(container: &mut Vec<Disk>, content: &str) {
     container.clear();
     // The goal of this array is to list all removable devices (the ones whose name starts with
     // "usb-").
@@ -283,7 +283,7 @@ fn get_all_disks(container: &mut Vec<Disk>, content: &str) {
 }
 
 // #[test]
-// fn check_all_disks() {
+// fn check_all_list() {
 //     let disks = get_all_disks_inner(
 //         r#"tmpfs /proc tmpfs rw,seclabel,relatime 0 0
 // proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
diff --git a/src/unknown/component.rs b/src/unknown/component.rs
index 5be9276..25320e1 100644
--- a/src/unknown/component.rs
+++ b/src/unknown/component.rs
@@ -35,11 +35,11 @@ impl ComponentsInner {
         }
     }
 
-    pub(crate) fn components(&self) -> &[Component] {
+    pub(crate) fn list(&self) -> &[Component] {
         &self.components
     }
 
-    pub(crate) fn components_mut(&mut self) -> &mut [Component] {
+    pub(crate) fn list_mut(&mut self) -> &mut [Component] {
         &mut self.components
     }
 
diff --git a/src/unknown/disk.rs b/src/unknown/disk.rs
index 2015519..f4cec7c 100644
--- a/src/unknown/disk.rs
+++ b/src/unknown/disk.rs
@@ -51,11 +51,11 @@ impl DisksInner {
         // Does nothing.
     }
 
-    pub(crate) fn disks(&self) -> &[Disk] {
+    pub(crate) fn list(&self) -> &[Disk] {
         &[]
     }
 
-    pub(crate) fn disks_mut(&mut self) -> &mut [Disk] {
+    pub(crate) fn list_mut(&mut self) -> &mut [Disk] {
         &mut []
     }
 }
diff --git a/src/windows/component.rs b/src/windows/component.rs
index aa32973..d1f392b 100644
--- a/src/windows/component.rs
+++ b/src/windows/component.rs
@@ -96,11 +96,11 @@ impl ComponentsInner {
         }
     }
 
-    pub(crate) fn components(&self) -> &[Component] {
+    pub(crate) fn list(&self) -> &[Component] {
         &self.components
     }
 
-    pub(crate) fn components_mut(&mut self) -> &mut [Component] {
+    pub(crate) fn list_mut(&mut self) -> &mut [Component] {
         &mut self.components
     }
 
diff --git a/src/windows/disk.rs b/src/windows/disk.rs
index 697b2b6..e7e5b18 100644
--- a/src/windows/disk.rs
+++ b/src/windows/disk.rs
@@ -87,15 +87,15 @@ impl DisksInner {
 
     pub(crate) fn refresh_list(&mut self) {
         unsafe {
-            self.disks = get_disks();
+            self.disks = get_list();
         }
     }
 
-    pub(crate) fn disks(&self) -> &[Disk] {
+    pub(crate) fn list(&self) -> &[Disk] {
         &self.disks
     }
 
-    pub(crate) fn disks_mut(&mut self) -> &mut [Disk] {
+    pub(crate) fn list_mut(&mut self) -> &mut [Disk] {
         &mut self.disks
     }
 }
@@ -143,7 +143,7 @@ unsafe fn get_drive_size(mount_point: &[u16]) -> Option<(u64, u64)> {
     }
 }
 
-pub(crate) unsafe fn get_disks() -> Vec<Disk> {
+pub(crate) unsafe fn get_list() -> Vec<Disk> {
     let drives = GetLogicalDrives();
     if drives == 0 {
         return Vec::new();


Test patch:
diff --git a/tests/disk_list.rs b/tests/disk_list.rs
index bae256e..6a98f4f 100644
--- a/tests/disk_list.rs
+++ b/tests/disk_list.rs
@@ -8,7 +8,7 @@ fn test_disks() {
         if s.physical_core_count().unwrap_or_default() > 0 {
             let mut disks = sysinfo::Disks::new();
             disks.refresh_list();
-            assert!(!disks.disks().is_empty());
+            assert!(!disks.list().is_empty());
         }
     }
 }