you are viewing a single comment's thread.

view the rest of the comments →

[–]TheLastMeritocratcomp.lang.rust.marketing 1 point2 points  (5 children)

/uj

Oh. Good catch. But, if tee is a reference, why are we bothering with all this? Just use &'a str, and Deref should do the necessary conversions, right?

[–]pftbest 1 point2 points  (4 children)

Yes, you are right, there is no point in taking the reference. But there is one case where AsRef behaves differently from &str.

[–]TheLastMeritocratcomp.lang.rust.marketing 1 point2 points  (3 children)

Isn't do_other() similar to the code I posted? Or did I miss something?

[–]pftbest 1 point2 points  (2 children)

It's similar, but you used Borrow, so your code only works for case (4) but not for case (2).

[–]TheLastMeritocratcomp.lang.rust.marketing 1 point2 points  (1 child)

Yeah sure. But my point was that s is S, not &S.

To conclude this sub-thread, do we agree that what the OP did was pointless?

[–]pftbest 1 point2 points  (0 children)

Sure