Re: [PATCH v5 4/4] rust: adding OwnableRefCounted and SimpleOwnableRefCounted
From: Oliver Mangold
Date: Mon Mar 10 2025 - 03:08:32 EST
On 250307 1416, Miguel Ojeda wrote:
> Hi Oliver,
>
> Some general style nits for this and other series you may send in the
> future (not a review). Please note that most may apply several times.
>
> On Fri, Mar 7, 2025 at 11:04 AM Oliver Mangold <oliver.mangold@xxxxx> wrote:
> >
> > Types implementing one of these traits
> > can safely convert between an ARef<T> and an Owned<T>.
>
> The wrapping is strange here, and it also happens in your code
> comments. Please use the same width as the rest of the code in a file
> etc.
>
Sure, I can change that, no problem. Just to explain, I didn't give that
too much thought. I just tried to stick to the 100 chars max length.
I think I tended to try to split lines at places where it fits the
sentence structure to improve readability, but I guess you are right,
using up the maximum space is easier to the deal with
> > +/// - The same safety requirements as for [`Ownable`] and [`RefCounted`] apply.
> I wonder if we should expand/inline them, even if they come from the
> supertraits.
>
I tried to avoid copy-paste, but I can do if it is generally preferred.
Or can rustdoc include sections?
> > +/// - the uniqueness invariant of [`Owned`] is upheld until dropped.
>
> Please use uppercase to start sentences.
>
Ok. I think I mostly did, but seems I missed a few.
>
> "same" sounds like no extra requirements -- what about something like:
>
> The safety requirements from both [.....
>
> > +/// // Use a KBox to handle the actual allocation
>
> Please use Markdown for comments too, and period at the end (also for
> "SAFETY: ..." comments).
>
> > +/// // SAFETY: we implement the trait correctly by ensuring
>
> There is no need to say "we implement the trait correctly", i.e. the
> `SAFETY` tag is enough to introduce the comment; the same way we don't
> say "SAFETY: the following unsafe block is correct because ..." etc.
>
> > +/// }
> > +/// fn is_unique(&self) -> bool {
>
> Newline between items.
>
> > +/// let foo = Foo::new().unwrap();
>
> In general, we try to avoid showing patterns that people should avoid
> when writing actual code (at least in non-hidden code) -- could we
> avoid the `unwrap()`?
Sure, I will fix all of the above in the next release.
> > +// TODO: enable this when compiler supports it (>=1.85)
> > +// #[diagnostic::do_not_recommend]
>
On 250309 2247, Miguel Ojeda wrote:
>
> Oliver: I am sending a quick patch explaining this -- please feel free
> to pick it up in your series.
Thanks. I agree it is better not having to change this after compiler upgrade.
Best regards,
Oliver