Rust-for-linux archive mirror
 help / color / mirror / Atom feed
From: Yutaro Ohno <yutaro.ono.418@gmail.com>
To: Alice Ryhl <aliceryhl@google.com>,
	Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: a.hindborg@samsung.com, alex.gaynor@gmail.com,
	armavica@ulminfo.fr, benno.lossin@proton.me,
	bjorn3_gh@protonmail.com, boqun.feng@gmail.com, gary@garyguo.net,
	ojeda@kernel.org, rust-for-linux@vger.kernel.org,
	wedsonaf@gmail.com
Subject: Re: [PATCH V2] rust: str: implement `Display` and `Debug` for `BStr`
Date: Wed, 31 Jan 2024 13:58:14 +0900	[thread overview]
Message-ID: <ZbnTZjb9O4O6Y65_@ohnotp> (raw)
In-Reply-To: <20240129121859.1099000-1-aliceryhl@google.com>

Thank you both for the comments!

On 01/29, Miguel Ojeda wrote:
> On Mon, Jan 29, 2024 at 1:19 PM Alice Ryhl <aliceryhl@google.com> wrote:
> >
> > What about newlines and tabs? Those are printable.
> >
> > If you are intentionally excluding them, please add a comment saying that.
> 
> +1 and, either way, it would also nice a test for those too.

> > This escapes quotes, but what about backslashes?
> 
> Ditto.

Newlines and tabs are omitted here because this patch doesn't intend to
change the current behavior of CStr's Display/Debug in this patch,
aligning with the feedback provided in V1.

So, how about removing the changes to CStr's Display/Debug from my
patch, and adding '\t' and '\n' as printable characters to BStr's
Display/Debug? (Backslashes for Debug as well.)

I'm considering whether it would be preferable for BStr's Display and
Debug to have distinct behavior from CStr's.

On Mon, Jan 29, 2024 at 1:19 PM Alice Ryhl <aliceryhl@google.com> wrote:
> Also, perhaps `write_char('"')` makes more sense than `write_str("\"")`?

I agree. Will change in V3.

On 01/29, Alice Ryhl wrote:
> >  macro_rules! b_str {
> >      ($str:literal) => {{
> >          const S: &'static str = $str;
> > -        const C: &'static $crate::str::BStr = S.as_bytes();
> > +        const C: &'static $crate::str::BStr = BStr::from_bytes(S.as_bytes());
> >          C
> >      }};
> >  }
> 
> This should use the full path both times:
> 
> const C: &'static $crate::str::BStr = $crate::str::BStr::from_bytes(S.as_bytes());

Thanks. I'll also change this.


Best regards,
Yutaro Ohno

      parent reply	other threads:[~2024-01-31  4:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-27  4:16 [PATCH V2] rust: str: implement `Display` and `Debug` for `BStr` Yutaro Ohno
2024-01-29 12:18 ` Alice Ryhl
2024-01-29 17:26   ` Miguel Ojeda
2024-01-31  4:58   ` Yutaro Ohno [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZbnTZjb9O4O6Y65_@ohnotp \
    --to=yutaro.ono.418@gmail.com \
    --cc=a.hindborg@samsung.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=armavica@ulminfo.fr \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=gary@garyguo.net \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=wedsonaf@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).