Skip to content

feat: add PathSeg to public API#656

Merged
sunng87 merged 2 commits into
sunng87:masterfrom
geoffreygarrett:master
Jul 9, 2024
Merged

feat: add PathSeg to public API#656
sunng87 merged 2 commits into
sunng87:masterfrom
geoffreygarrett:master

Conversation

@geoffreygarrett

Copy link
Copy Markdown
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
Copy Markdown

Coverage Status

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

@sunng87

sunng87 commented Jul 7, 2024

Copy link
Copy Markdown
Owner

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

@coveralls

Copy link
Copy Markdown

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
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