-
Notifications
You must be signed in to change notification settings - Fork 11
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
Provide LenTextSize for Arc<String> #36
Conversation
let s = StringLike(""); | ||
let _ = TextSize::of(&s); | ||
test! { | ||
"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we test ::of("")
(without &) anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the doc-tests for TextSize::of
, yes, but I'm going to add it here as well.
Hm, could you also check that this impl allows downstream crates to impl the trait? rowan's SyntaxNodeText comes into mind. |
I guess, we can actually put this into an integration, test because it is a downstream crate. |
For my own sanity, here's a (nonexhaustive) list of types we definitely want to be (able to be) accepted:
And types that don't have to be accepted, but would be nice to:
I think we almost get what we want from |
Based on further experimentation, I think we have to just accept that this is a limitation of the Rust language that deref coersion is not occurring here, and tell users to deref their smart pointers to |
What about removing blanket impls and just adding a tone of impls manually? |
Yeah, that seems to be the best bet. I'm doing such now. |
Unfortunately, this impl leads to infinite recursion for, say
&()
, or any reference type that doesn't implLenTextSize
.Cow::Owned(String::new())
falls into this trap via the type inference variable for theB
inCow<'_, B>
.I've reported the wonderful error which isn't even being caught by the "recursive requirements" folder.
I have some alternate constructions to try, but I'm putting this one in the pool before I forget that
&Arc<String>
should be accepted byTextSize::of
.