Skip to content

Commit

Permalink
inline function source code and remove annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Easyoakland committed Aug 9, 2023
1 parent 87ad574 commit 068de35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3857,10 +3857,12 @@ pub trait Itertools : Iterator {
/// assert_eq!((10..).try_len(), Err((usize::MAX, None)));
/// assert_eq!((10..15).filter(|x| x % 2 == 0).try_len(), Err((0, Some(5))));
/// ```
#[inline]
fn try_len(&self) -> Result<usize, size_hint::SizeHint>
{
size_hint::try_len(self.size_hint())
fn try_len(&self) -> Result<usize, size_hint::SizeHint> {
let sh = self.size_hint();
match sh {
(lo, Some(hi)) if lo == hi => Ok(lo),
_ => Err(sh),
}
}
}

Expand Down
9 changes: 0 additions & 9 deletions src/size_hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,3 @@ pub fn min(a: SizeHint, b: SizeHint) -> SizeHint {
};
(lower, upper)
}

/// Returns the length of the iterator if one exists.
#[inline]
pub fn try_len(sh: SizeHint) -> Result<usize, SizeHint> {
match sh {
(lo, Some(hi)) if lo == hi => Ok(lo),
_ => Err(sh)
}
}

0 comments on commit 068de35

Please sign in to comment.