Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Ockajak committed Jul 11, 2024
1 parent cc8e5bc commit 7f0b0a9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ data.group_by(|x| x % 2); // HashMap::from([(0, vec![2]), (1, vec![1, 3]
| *map_while* | :heavy_check_mark: | | | |
| *max_by* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| *max_by_key* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| *max_item* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| *max_of* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| *min_by* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| *min_by_key* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| *min_item* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| *min_of* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| *minmax_by* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| *minmax_by_key* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| *minmax_item* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| *minmax_of* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| *move_at* | :heavy_check_mark: | | | |
| *multicombinations* | :heavy_check_mark: | | | |
| *pad_left* | :heavy_check_mark: | | | |
Expand Down
18 changes: 9 additions & 9 deletions src/extensions/traversable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,12 @@ pub trait Traversable<Item> {
/// let a = vec![1, 2, 3];
/// let e: Vec<u32> = Vec::new();
///
/// assert_eq!(a.max_item(), Some(&3));
/// assert_eq!(a.max_of(), Some(&3));
///
/// assert_eq!(e.max_item(), None);
/// assert_eq!(e.max_of(), None);
/// ```
#[inline]
fn max_item(&self) -> Option<&Item>
fn max_of(&self) -> Option<&Item>
where
Item: Ord,
{
Expand Down Expand Up @@ -382,12 +382,12 @@ pub trait Traversable<Item> {
/// let a = vec![1, 2, 3];
/// let e: Vec<i32> = Vec::new();
///
/// assert_eq!(a.min_item(), Some(&1));
/// assert_eq!(a.min_of(), Some(&1));
///
/// assert_eq!(e.min_item(), None);
/// assert_eq!(e.min_of(), None);
/// ```
#[inline]
fn min_item(&self) -> Option<&Item>
fn min_of(&self) -> Option<&Item>
where
Item: Ord,
{
Expand Down Expand Up @@ -448,11 +448,11 @@ pub trait Traversable<Item> {
/// let a = vec![-3_i32, 0, 1, 5, -10];
/// let e: Vec<i32> = Vec::new();
///
/// assert_eq!(a.minmax_item(), Some((&-10, &5)));
/// assert_eq!(e.minmax_item(), None);
/// assert_eq!(a.minmax_of(), Some((&-10, &5)));
/// assert_eq!(e.minmax_of(), None);
/// ```
#[inline]
fn minmax_item(&self) -> Option<(&Item, &Item)>
fn minmax_of(&self) -> Option<(&Item, &Item)>
where
Item: Ord,
{
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@
/// | *map_while* | :heavy_check_mark: | | | |
/// | *max_by* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
/// | *max_by_key* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
/// | *max_item* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
/// | *max_of* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
/// | *min_by* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
/// | *min_by_key* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
/// | *min_item* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
/// | *min_of* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
/// | *minmax_by* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
/// | *minmax_by_key* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
/// | *minmax_item* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
/// | *minmax_of* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
/// | *move_at* | :heavy_check_mark: | | | |
/// | *multicombinations* | :heavy_check_mark: | | | |
/// | *pad_left* | :heavy_check_mark: | | | |
Expand Down
18 changes: 9 additions & 9 deletions tests/extensions/traversable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ where
assert_eq!(repeated.max_by(i64::cmp), Some(&2));
assert_eq!(empty.max_by(i64::cmp), None);

// max_item
assert_eq!(repeated.max_item(), Some(&2));
assert_eq!(empty.max_item(), None);
// max_of
assert_eq!(repeated.max_of(), Some(&2));
assert_eq!(empty.max_of(), None);

// min_by
assert_eq!(repeated.min_by(i64::cmp), Some(&0));
assert_eq!(empty.min_by(i64::cmp), None);

// min_item
assert_eq!(repeated.min_item(), Some(&0));
assert_eq!(empty.min_item(), None);
// min_of
assert_eq!(repeated.min_of(), Some(&0));
assert_eq!(empty.min_of(), None);

//minmax_item
assert_eq!(repeated.minmax_item(), Some((&0, &2)));
assert_eq!(empty.minmax_item(), None);
//minmax_of
assert_eq!(repeated.minmax_of(), Some((&0, &2)));
assert_eq!(empty.minmax_of(), None);
}
3 changes: 2 additions & 1 deletion tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ fn sequences() {
let vec: Vec<i64> = Vec::new();
let vec_deque: VecDeque<i64> = VecDeque::new();
let linked_list: LinkedList<i64> = LinkedList::new();
let _ = (vec.len(), linked_list.len(), vec_deque.len());
let slice = &vec[..];
let _ = (slice.len(), vec.len(), linked_list.len(), vec_deque.len());
test_sequence_traits(vec);
test_list_traits(linked_list);
test_list_traits(vec_deque);
Expand Down

0 comments on commit 7f0b0a9

Please sign in to comment.