When requesting a configuration property in a context that infers `&str`, the method fails
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 265
- Avg merge
- 2h 42m
- Merged PRs (30d)
- 4
Description
let redis_client = redis::Client::open(settings.get("redis_url").unwrap()).unwrap();
invalid type: string "...", expected a borrowed string
This is because of type conversions. We must return a String because there may have been a type conversion.
I can see this fixed in two ways:
- Fix this by allowing to get out a
&strif the underlying value is stored as a String. I don't like this because it'd only work sometimes. - Fix this by storing the type conversion in the cache when the value is requested. This makes a kind of sense because I believe we can optimize for users requesting the same type of value over-and-over-again. I was already going to add an initial "guess" that losslessly converts your incoming config value on the assumption that if you give us a
"1"through an environment variable you probably meant1.
As a side note I'm starting a medium-large project in Rust (finally) and am using this crate. Hopefully will find a ton of usage issues and annoyances (like this).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the settings.get("redis_url") call used as an argument to redis::Client::open, then trace the configuration value conversion and caching path. The issue is done when requesting a converted configuration value in a context inferring &str behaves correctly, with regression coverage for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100