Skip to content

feat(core): add NonEmpty<T>#1444

Merged
Benoît Cortier (CBenoit) merged 1 commit into
masterfrom
feat/core-nonempty
Jul 13, 2026
Merged

feat(core): add NonEmpty<T>#1444
Benoît Cortier (CBenoit) merged 1 commit into
masterfrom
feat/core-nonempty

Conversation

@CBenoit

Copy link
Copy Markdown
Member

Add a NonEmpty<T> collection guaranteeing at least one element. The first element (head) is stored inline, so a single-element NonEmpty performs no heap allocation, and first() is infallible while len() returns a NonZeroUsize, and callers never branch on an "is it empty?" case.

Add a `NonEmpty<T>` collection guaranteeing at least one element. The
first element (head) is stored inline, so a single-element `NonEmpty`
performs no heap allocation, and `first()` is infallible while `len()`
returns a `NonZeroUsize`, and callers never branch on an "is it empty?"
case.
Copilot AI review requested due to automatic review settings July 13, 2026 07:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a small NonEmpty<T> collection to ironrdp-core (behind the alloc feature) to model “at least one element” sequences efficiently: the first element is stored inline to avoid heap allocation for single-element cases, while still providing ergonomic iteration and filtering.

Changes:

  • Introduces NonEmpty<T> with inline head + Vec<T> tail, plus first(), len() -> NonZeroUsize, iter(), and filter().
  • Implements IntoIterator for both owned NonEmpty<T> and &NonEmpty<T>.
  • Wires the module and re-export into ironrdp-core behind #[cfg(feature = "alloc")].

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/ironrdp-core/src/non_empty.rs New NonEmpty<T> type with inline head storage, non-zero length, and iterator/filter APIs.
crates/ironrdp-core/src/lib.rs Adds non_empty module and re-exports NonEmpty under the alloc feature gate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CBenoit Benoît Cortier (CBenoit) enabled auto-merge (squash) July 13, 2026 07:46
@CBenoit Benoît Cortier (CBenoit) merged commit bdcc0ce into master Jul 13, 2026
23 checks passed
@CBenoit Benoît Cortier (CBenoit) deleted the feat/core-nonempty branch July 13, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants