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: allow using str in HashMaps with a PackageName key #468

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

baszalmstra
Copy link
Collaborator

@baszalmstra baszalmstra commented Jan 5, 2024

Adds a Borrow<str> implementation for PackageName.

This allows indexing HashMaps with a PackageName as key with a str. e.g.:

fn get_package_version(map: &HashMap<PackageName, Version>) -> Option<&Version> {
    maps.get("normalized_package_name")
}

just works.

Previously you would have to write:

fn get_package_version(map: &HashMap<PackageName, Version>) -> Option<&Version> {
    maps.get(PackageName::from_str("normalized_package_name").unwrap())
}

Similar to prefix-dev/rip#89

@baszalmstra baszalmstra requested a review from wolfv January 5, 2024 13:54
@baszalmstra baszalmstra merged commit 305008d into conda:main Jan 5, 2024
13 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.

1 participant