Re: [PATCH v3 1/2] rust: non_empty: add NonEmpty

From: Miguel Ojeda

Date: Thu Oct 15 2026 - 10:09:07 EST


On Wed, Oct 14, 2026 at 4:25 PM Gary Guo <gary@xxxxxxxxxxx> wrote:
>
> I think in this case the meaning of "empty" depends on the container itself.
> Unsafe code that relies on "is_empty" would be the `NonEmpty<Container>` itself,
> so it just needs to trust itself (as boundary of unsafe is module level).
>
> I think of almost all of the text above can be removed. The invariant of
> `NonEmpty` can just be "`IsEmpty::is_empty` has returned true" and how it is
> interpreted is up to the container type.

That sounds good to me, i.e. my main concern was the invariant text.

(Though we still mark things as `unsafe` even if private and within a
module, so if we are actually trusting it, shouldn't we mark it?)

Cheers,
Miguel