Skip to content

Commit ef60de1

Browse files
committed
fix: NonEmpty::capacity returns NonZeroUsize
1 parent 5442b77 commit ef60de1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this library adheres to Rust's notion of
66
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 0.12.0
9+
- `NonEmpty::capacity` returns `NonZeroUsize`
10+
811
## 0.11.0
912

1013
### Added

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ impl<T> NonEmpty<T> {
349349
}
350350

351351
/// Get the capacity of the list.
352-
pub fn capacity(&self) -> usize {
353-
self.tail.capacity() + 1
352+
pub fn capacity(&self) -> NonZeroUsize {
353+
NonZeroUsize::MIN.saturating_add(self.tail.capacity())
354354
}
355355

356356
/// Get the last element. Never fails.

0 commit comments

Comments
 (0)