Skip to content

Commit

Permalink
nonzero
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed Nov 1, 2024
1 parent 9bf3f5c commit c195b03
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions range-requests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,11 @@ impl SingleRange {
.expect("Range bounds should have been ASCII string")
}

pub fn content_length(&self) -> u64 {
assert!(self.range.length > 0);

self.range.length
/// Returns the content length for this range
pub fn content_length(&self) -> std::num::NonZeroU64 {
self.range.length.try_into().expect(
"Length should be more than zero, validated in SingleRange::new",
)
}
}

Expand Down

0 comments on commit c195b03

Please sign in to comment.