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

feat: add PathSeg to public API #656

Merged
merged 2 commits into from
Jul 9, 2024
Merged

Conversation

geoffreygarrett
Copy link
Contributor

Rationale:

I'm doing a bit of code generation from the parsed template, and in order to generate based on:

Path(
    Relative(
        ( 
            [Named("visibility")],
            "visibility",
        ),
    ),
),

I've been using the following workaround, which is far from ideal:

fn path_to_string(path: &Path) -> String {
    let raw_path = format!("{:?}", path);
    let regex = regex::Regex::new(r#"(?:"|\\")([^\\"]+)(?:"|\\")"#).unwrap();
    if let Some(captures) = regex.captures(&raw_path) {
        captures.get(1).unwrap().as_str().to_string()
    } else {
        raw_path
    }
}

Making PathSeg part of the public API allows for cleaner and more direct usage, eliminating the need for such workarounds.

Thank you for your consideration.

This commit introduces the `PathSeg` enum to the public API in `lib.rs`.
@coveralls
Copy link

Coverage Status

coverage: 81.191%. remained the same
when pulling 694b980 on geoffreygarrett:master
into 57454fc on sunng87:master.

@sunng87
Copy link
Owner

sunng87 commented Jul 7, 2024

Thank you! Could you please add #[non_exhaustive] to PathSeg as well? We need that attribute for public members.

@coveralls
Copy link

Coverage Status

coverage: 81.457% (+0.3%) from 81.191%
when pulling c3a4e5f on geoffreygarrett:master
into 57454fc on sunng87:master.

@sunng87 sunng87 merged commit 95a53a8 into sunng87:master Jul 9, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants