jonhoo / rust-imap

IMAP client library for Rust
Apache License 2.0
477 stars 80 forks source link

Implement From<String> for QuotaResourceName #272

Closed urkle closed 11 months ago

urkle commented 11 months ago

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[bot] commented 11 months ago

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%) :arrow_up:

... and 1 file with indirect coverage changes

jonhoo commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

@jonhoo updated