Skip to content
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

Add IpDisplayBuffer helper struct. #100625

Merged
merged 4 commits into from
Aug 16, 2022
Merged

Conversation

reitermarkus
Copy link
Contributor

This removes the dependency on std::io::Write for implementing Display, allowing it to be moved to core as proposed in rust-lang/rfcs#2832.

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Aug 16, 2022
@rustbot
Copy link
Collaborator

rustbot commented Aug 16, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-highfive
Copy link
Collaborator

r? @thomcc

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 16, 2022
@reitermarkus reitermarkus force-pushed the ip-display-buffer branch 2 times, most recently from 3f769ac to ccf3128 Compare August 16, 2022 12:57
@reitermarkus reitermarkus force-pushed the ip-display-buffer branch 2 times, most recently from ff33f03 to 220b01e Compare August 16, 2022 13:16
library/std/src/net/ip.rs Outdated Show resolved Hide resolved
library/std/src/net/ip.rs Outdated Show resolved Hide resolved
library/std/src/net/ip.rs Outdated Show resolved Hide resolved

impl<const SIZE: usize> fmt::Write for IpDisplayBuffer<SIZE> {
fn write_str(&mut self, s: &str) -> fmt::Result {
if let Some(buf) = self.buf.get_mut(self.len..(self.len + s.len())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: There is no overflow bug here because if it overflows the end will be less than beginning and get_mut will just return None which is intended.

library/std/src/net/ip.rs Outdated Show resolved Hide resolved
library/std/src/net/ip/display_buffer.rs Outdated Show resolved Hide resolved
library/std/src/net/ip/display_buffer.rs Outdated Show resolved Hide resolved
@reitermarkus reitermarkus requested review from thomcc and removed request for Kixunil August 16, 2022 17:33
@thomcc
Copy link
Member

thomcc commented Aug 16, 2022

lgtm

@bors r+

@bors
Copy link
Contributor

bors commented Aug 16, 2022

📌 Commit 44d6242 has been approved by thomcc

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 16, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 16, 2022
Rollup of 4 pull requests

Successful merges:

 - rust-lang#100243 (Remove opt_remap_env_constness from rustc_query_impl)
 - rust-lang#100625 (Add `IpDisplayBuffer` helper struct.)
 - rust-lang#100629 (Use `merged_ty` method instead of rewriting it every time)
 - rust-lang#100630 (rustdoc JSON: Fix ICE with `pub extern crate self as <self_crate_name>`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b7b4f79 into rust-lang:master Aug 16, 2022
@rustbot rustbot added this to the 1.65.0 milestone Aug 16, 2022
@reitermarkus reitermarkus deleted the ip-display-buffer branch August 17, 2022 12:54
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 25, 2022
…, r=thomcc

Use `DisplayBuffer` for socket addresses.

Continuation of rust-lang#100625 for socket addresses.

Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 25, 2022
…, r=thomcc

Use `DisplayBuffer` for socket addresses.

Continuation of rust-lang#100625 for socket addresses.

Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 26, 2022
…, r=thomcc

Use `DisplayBuffer` for socket addresses.

Continuation of rust-lang#100625 for socket addresses.

Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 26, 2022
…, r=thomcc

Use `DisplayBuffer` for socket addresses.

Continuation of rust-lang#100625 for socket addresses.

Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 26, 2022
…, r=thomcc

Use `DisplayBuffer` for socket addresses.

Continuation of rust-lang#100625 for socket addresses.

Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 27, 2022
…, r=thomcc

Use `DisplayBuffer` for socket addresses.

Continuation of rust-lang#100625 for socket addresses.

Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 28, 2022
…, r=thomcc

Use `DisplayBuffer` for socket addresses.

Continuation of rust-lang#100625 for socket addresses.

Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 29, 2022
…, r=thomcc

Use `DisplayBuffer` for socket addresses.

Continuation of rust-lang#100625 for socket addresses.

Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 1, 2022
…, r=thomcc

Use `DisplayBuffer` for socket addresses.

Continuation of rust-lang#100625 for socket addresses.

Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Sep 1, 2022
…, r=thomcc

Use `DisplayBuffer` for socket addresses.

Continuation of rust-lang#100625 for socket addresses.

Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 13, 2022
…r=thomcc

Use `DisplayBuffer` for socket addresses.

Continuation of rust-lang#100625 for socket addresses.

Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
workingjubilee pushed a commit to tcdi/postgrestd that referenced this pull request Sep 15, 2022
Use `DisplayBuffer` for socket addresses.

Continuation of rust-lang/rust#100625 for socket addresses.

Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Sep 22, 2022
Use `DisplayBuffer` for socket addresses.

Continuation of rust-lang/rust#100625 for socket addresses.

Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants