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

Implement From<String> for QuotaResourceName #272

Merged
merged 1 commit into from
Oct 7, 2023

Conversation

urkle
Copy link
Contributor

@urkle urkle commented Sep 27, 2023

In using the quota feature in my application (finally) I noticed that I was running into life-time specifier issues trying to convert my input String into a QuotaResourceLimit through the Into argument.

I had to resort to re-implementing my own match line to convert into an Owned QuotaResourceName.

This PR adds an implementation of From for QuotaResourceName<'_> so strings can be utilized as well as &str.


This change is Reviewable

@codecov
Copy link

codecov bot commented Sep 27, 2023

Codecov Report

Merging #272 (245a6ca) into main (ce87f7d) will increase coverage by 0.3%.
The diff coverage is 100.0%.

Files Coverage Δ
src/types/quota.rs 92.5% <100.0%> (+4.9%) ⬆️

... and 1 file with indirect coverage changes

@jonhoo
Copy link
Owner

jonhoo commented Oct 3, 2023

Hmm, this doesn't seem quite right — it means there's no way to avoid turning it into an owned string. Wouldn't it be better to impl From<String> for QuotaResourceName<'static> in addition instead?

@urkle
Copy link
Contributor Author

urkle commented Oct 5, 2023

Hmm, this doesn't seem quite right — it means there's no way to avoid turning it into an owned string. Wouldn't it be better to impl From<String> for QuotaResourceName<'static> in addition instead?

Yup.. that makes better sense. I knew this was "fishy", just wasn't sure how to easily fix it.

@urkle urkle force-pushed the fix-quota-resource-name-from branch from 9fc59c1 to cc5944d Compare October 5, 2023 03:24
@urkle urkle changed the title Change lifetime specifier for From<&str> for QuotaResourceName Implement From<String> for QuotaResourceName Oct 5, 2023
@urkle
Copy link
Contributor Author

urkle commented Oct 5, 2023

@jonhoo updated

- otherwise in common use-cases one cannot convert a String easily into a QuotaResourceName
@urkle urkle force-pushed the fix-quota-resource-name-from branch from cc5944d to 245a6ca Compare October 5, 2023 19:18
Copy link
Owner

@jonhoo jonhoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thank you!

@jonhoo jonhoo merged commit 2bd38aa into jonhoo:main Oct 7, 2023
16 of 18 checks passed
@urkle urkle deleted the fix-quota-resource-name-from branch October 11, 2023 14:49
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.

2 participants