Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MountInfos::iter #300

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions procfs-core/src/process/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ bitflags! {
/// This data is taken from the `/proc/[pid]/mountinfo` file.
pub struct MountInfos(pub Vec<MountInfo>);

impl MountInfos {
/// Returns an borrowed iterator.
pub fn iter(&self) -> std::slice::Iter<'_, MountInfo> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a minor point, but I wonder if we could do:

Suggested change
pub fn iter(&self) -> std::slice::Iter<'_, MountInfo> {
pub fn iter(&self) -> impl Iterator<Item = &MountInfo> {

to hide the std::slice::Iter concrete type. In practice this doesn't matter much because the inner Vec is part of the public API of MountInfos (and so std::slice::Iter is kind of part of this API too)

self.into_iter()
}
}

impl crate::FromBufRead for MountInfos {
fn from_buf_read<R: BufRead>(r: R) -> ProcResult<Self> {
let lines = r.lines();
Expand Down
Loading