All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: Andreas Hindborg <nmi@metaspace.dk>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Benno Lossin <benno.lossin@proton.me>,
	Jens Axboe <axboe@kernel.dk>,
	Andreas Hindborg <a.hindborg@samsung.com>,
	Boqun Feng <boqun.feng@gmail.com>,
	linux-block@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH RESEND] block, rust: simplify validate_block_size() function
Date: Tue, 3 Sep 2024 12:47:04 -0700	[thread overview]
Message-ID: <ZtdnuH9lWtsPCg-X@google.com> (raw)
In-Reply-To: <CANiq72=GRbxY=3-NP6RutcJjCqRxRftafVZqDD73tureOh20Ew@mail.gmail.com>

On Tue, Sep 03, 2024 at 09:30:53PM +0200, Miguel Ojeda wrote:
> On Tue, Sep 3, 2024 at 9:00 PM Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> >
> > If you want to keep dividing into Rust-land and C-land I'm afraid you
> > will have 2 islands that do not talk to each other. I really want to be
> 
> We are not trying to divide the Rust and C side, quite the opposite.
> That should be obvious since dividing both sides only hurts the
> project to begin with.
> 
> > able to parse the things quickly and not constantly think if my Rust is
> > idiomatic enough or I could write the code in a more idiomatic way with
> > something brand new that just got off the nightly list and moved into
> > stable.
> 
> If a feature is in the minimum support version we have for Rust in the
> kernel, and it improves the way we write code, then we should consider
> taking advantage of it.
> 
> Now, that particular function call would have compiled since Rust 1.35
> and ranges were already a concept back in Rust 1.0. So I am not sure
> why you mention recently stabilized features here.

I was talking in general, not about this exact case, sorry if I was
unclear. But in general I personally have this issue with Rust and to
extent also with C++ where I constantly wonder if my code is "idiomatic
enough" or if it looks obsolete because it is "only" C++14 and not 17
or 20.

With C usually have no such concerns which allows me to concentrate on
different things.

> 
> For this particular case, I don't think it matters too much, and I can
> see arguments both ways (and we could introduce other ways to avoid
> the reference or swap the order, e.g. `n.within(a..b)`).
> 
> > This is a private function and an implementation detail. Why does it
> > need to be exposed in documentation at all?
> 
> That is a different question -- but even if it should be a private
> function, it does not mean documentation should be removed (even if
> currently we do not require documentation for private items).

I think exposing documentation for private function that can change at
any time and is not callable from outside has little value. That does
not mean that comments annotating such function have no value. But they
need to be taken together with the function code, and in this case
Alexey's concern about comments like "this increments that by 1"
becomes quite valid.

Thanks.

-- 
Dmitry

  reply	other threads:[~2024-09-03 19:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-02  9:57 [PATCH RESEND] block, rust: simplify validate_block_size() function Andreas Hindborg
2024-09-03 19:00 ` Dmitry Torokhov
2024-09-03 19:30   ` Miguel Ojeda
2024-09-03 19:47     ` Dmitry Torokhov [this message]
2024-09-03 20:24       ` Benno Lossin
2024-09-03 20:31       ` Miguel Ojeda
  -- strict thread matches above, loose matches on Subject: below --
2024-08-31 20:15 Alexey Dobriyan
2024-08-31 20:39 ` Benno Lossin
2024-09-01 19:56   ` Alexey Dobriyan
2024-09-02  8:18     ` Benno Lossin

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=ZtdnuH9lWtsPCg-X@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=a.hindborg@samsung.com \
    --cc=adobriyan@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=benno.lossin@proton.me \
    --cc=boqun.feng@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=nmi@metaspace.dk \
    --cc=rust-for-linux@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.