-
Notifications
You must be signed in to change notification settings - Fork 301
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
Consider renaming Buf::bytes()
and BufMut::bytes_mut()
#447
Comments
@tokio-rs/maintainers Anyone have thoughts? If there isn't any support for a change here, I am inclined to just let it be. |
I agree that the current name could be misleading, and my knee-jerk reaction to |
I support changing it to |
As a data point, this personally bit me because I didn't read the docs. It doesn't help that if you have a Maybe |
NP-hard Question: Is the sum of time saved for new users (by reduced confusion) strictly greater than ( |
I would bet that there are downstream users that will discover buggy code when the name changes... |
Can we deprecate aliases of old names, to amortize the cost for downstream? |
We are not going to publish bytes v1.0.0 containing a deprecated method. That's just silly. |
I think the idea is that we would publish a point version of 0.6 that adds the new names as aliases to the old ones, and deprecates the old ones, as an "advance warning" to users prior to upgrading to 1.0? |
That's fine with me. |
Yeah, like in the same way that following Semver is silly? My idea was/is to include it deprecated in 1.0, silly be damned. The confusion avoidance is still achieved that way, possibly with even more context to show that the name has changed. Edit: And your idea, @hawkw, is compatible with mine, but I don't know if that is worth the trouble. |
@rcoh I did consider |
|
In that case, what about |
why not just |
The `bytes()` / `bytes_mut()` name implies the method returns the full set of bytes represented by `Buf`/`BufMut`. To rectify this, the methods are renamed to `chunk()` and `chunk_mut()` to reflect the partial nature of the returned byte slice. Closes #447
Maybe, but for every one of those, there will be two more silly users that will just blindly search and replace rename the method calls. That's certainly my plan! 🥇 Similar to the busy work inflicted by #433, in practical terms. 2¢ |
We can't save everyone. But, if the changelog entry about the rename mentions "this change was motivated by noticing users frequently misunderstanding how it works", that might convince some of those to consider if they should analyze each place they used it. |
But if there was a deprecation warning on compile, that warning could say the same, and that might be more noticeable to the more silly users? |
Its a trait, so is the deprecation suggestion being ignored more so because its hard to pull off with a trait method? |
I'd be in favor of a deprecation warning, for sure! I think it's trickier for this trait method, since we have to add a default for the new method, and implementors need to include the implementation (I think adding |
Well, if its reasonably easy to do, I'm in favor of doing it. +2¢ |
The `bytes()` / `bytes_mut()` name implies the method returns the full set of bytes represented by `Buf`/`BufMut`. To rectify this, the methods are renamed to `chunk()` and `chunk_mut()` to reflect the partial nature of the returned byte slice. `bytes_vectored()` is renamed `chunks_vectored()`. Closes #447
These two functions are named in a way that implies they return the entire set of bytes represented by the
Buf
/BufMut
.Some options:
window()
/window_mut()
chunk()
/chunk_mut()
.fragment()
/fragment_mut()
The text was updated successfully, but these errors were encountered: