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

HighlightingAssets: Extract new public API method get_syntax_for_path() #1862

Merged
merged 3 commits into from
Sep 28, 2021

Conversation

Enselic
Copy link
Collaborator

@Enselic Enselic commented Sep 25, 2021

We do this mainly to reduce duplication of logic. The move to adjust the public API is more of a side effect. It so happens that adjusting the public API also simplifies the code.

One of the reasons this refactoring works is that the .file_name() of a file_name is file_name unchanged:

    #[test]
    fn file_name_of_file_name_is_same() {
        let path = Path::new("test.rs");
        let expected = Path::new("test.rs");
        assert_eq!(path.file_name().unwrap_or_default(), expected);
    }

To make the code easier to refactor further.
…tax_for_path()

We can do this since the file_name() of a file_name is file_name.
src/assets.rs Outdated Show resolved Hide resolved
@Enselic Enselic changed the title HighlightingAssets: Add get_syntax_for_path() helper HighlightingAssets: Extract new public API method get_syntax_for_path() Sep 25, 2021
CHANGELOG.md Outdated Show resolved Hide resolved
@Enselic Enselic force-pushed the add-get_syntax_for_path-helper branch from 055538d to 972bbcf Compare September 28, 2021 04:47
@Enselic Enselic merged commit 405a80f into sharkdp:master Sep 28, 2021
@Enselic Enselic deleted the add-get_syntax_for_path-helper branch September 28, 2021 05:26
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.

None yet

2 participants