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

Tracking Issue for MAIN_SEPARATOR_STR #94071

Closed
1 of 3 tasks
SUPERCILEX opened this issue Feb 17, 2022 · 4 comments · Fixed by #103104
Closed
1 of 3 tasks

Tracking Issue for MAIN_SEPARATOR_STR #94071

SUPERCILEX opened this issue Feb 17, 2022 · 4 comments · Fixed by #103104
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@SUPERCILEX
Copy link
Contributor

SUPERCILEX commented Feb 17, 2022

Feature gate: #![feature(main_separator_str)]

This is a tracking issue for adding a static path separator str to match the static char already available.

Public API

pub const MAIN_SEPARATOR: char = '/';
pub const MAIN_SEPARATOR_STR: &str = "/";

Steps / History

Unresolved Questions

Can we combine the char and str API into one type that AsRefs to char, str, u8 etc. as needed?

@SUPERCILEX SUPERCILEX added C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Feb 17, 2022
@Brisklemonade
Copy link

What's the status on this?

@SUPERCILEX
Copy link
Contributor Author

Probs still waiting on using AsRef.

@SUPERCILEX
Copy link
Contributor Author

SUPERCILEX commented Oct 16, 2022

@yaahc I gave your idea a go, but I don't think it makes sense:

pub struct Separator;

impl Separator {
    pub const STR: &str = crate::sys::path::MAIN_SEP_STR;
    pub const CHAR: char = crate::sys::path::MAIN_SEP;
}

impl Deref for Separator {
    type Target = str;

    fn deref(&self) -> &Self::Target {
        Self::STR
    }
}

impl AsRef<str> for Separator {
    fn as_ref(&self) -> &str {
        self
    }
}

impl AsRef<char> for Separator {
    fn as_ref(&self) -> &char {
        &Self::CHAR
    }
}

Hiding the str and char behind a type doesn't really help because the type isn't opaque. People are presumably coming to do low-level stuff with the &str or char so we can't get rid of those constants. Maybe if every API had been designed from the start to take in a Separator this would have made more sense, but as it stands I actually think having a MAIN_SEP_STR constant is perfectly reasonable. At the very least, adding this constant doesn't block any future work (it would just get deprecated/forgotten).

On that note, how do I start an FCP?

JohnTitor pushed a commit to JohnTitor/rust that referenced this issue Jan 8, 2023
@klensy
Copy link
Contributor

klensy commented Jan 8, 2023

In topic: path separator named static when in actually const, but in this example it have possibly no difference.

@bors bors closed this as completed in ed77ffe Jan 8, 2023
thomcc pushed a commit to tcdi/postgrestd that referenced this issue May 31, 2023
Stabilize `main_separator_str`

See reasoning here: rust-lang/rust#94071 (comment). Closes #94071.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants