Add Shared type to fix inference fail on nightly #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there!
In rust-lang/rust#42565 some new impls were added to
Arc
and friends that are breaking type inference on this crate for string keys/values. This was originally reported here.The trait bounds here worked previously because we only had
impl<T> From<T> for Arc<T>
in the standard library, so in the boundArc<T>: From<U>
,U
could only ever beT
. That's not the case anymore, so Rust can't figure out whatT
should be fromU
. I'm assuming the reason for these bounds here was so that you could pass eitherT
orArc<T>
to some of the datastructures and have it do the right thing.To work around this I've added a trait that's implemented only for
T
andArc<T>
, so when we get a genericT: Shared<U>
we know thatT
must be eitherU
orArc<U>
. I haven't tried to come up with a good name for this trait or add any docs, in case this isn't the way you want to solve this problem.This is technically a breaking change. An alternative solution is that callers will just need to give Rust a hand and specify the type of maps and things when it can't figure it out itself.
cc: @bodil