Skip to content

std: use a TAIT to define SplitPaths on UNIX #145242

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joboet
Copy link
Member

@joboet joboet commented Aug 11, 2025

Defining SplitPaths as a TAIT allows using closures instead of function pointers for split and map.

@rustbot
Copy link
Collaborator

rustbot commented Aug 11, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 11, 2025
@theemathas

This comment was marked as off-topic.

@theemathas

This comment was marked as off-topic.

@joboet
Copy link
Member Author

joboet commented Aug 11, 2025

Note that this does not concern the public SplitPaths, but rather the inner SplitPaths that is wrapped by it.

pub struct SplitPaths<'a> {
iter: iter::Map<slice::Split<'a, u8, fn(&u8) -> bool>, fn(&'a [u8]) -> PathBuf>,
}
pub type SplitPaths<'a> = impl Iterator<Item = PathBuf> + 'a;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these items be pub(crate) if so?

We'd rather not be exposing a TAIT to downstream code, I imagine, so it might be better to enforce that with proper visibility:

Suggested change
pub type SplitPaths<'a> = impl Iterator<Item = PathBuf> + 'a;
pub(crate) type SplitPaths<'a> = impl Iterator<Item = PathBuf> + 'a;

Copy link
Member Author

Choose a reason for hiding this comment

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

None of the items in sys is exposed publicly, but we still use pub instead of pub(crate) almost everywhere. I don't really want to break the pattern and cause unnecessary confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants