Skip to content

Commit bc20afd

Browse files
committed
renamed feature and function back to contains
1 parent 3e3ccd8 commit bc20afd

File tree

4 files changed

+44
-44
lines changed

4 files changed

+44
-44
lines changed

library/core/src/iter/traits/iterator.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ pub trait Iterator {
7979
#[stable(feature = "rust1", since = "1.0.0")]
8080
fn next(&mut self) -> Option<Self::Item>;
8181

82-
/// Advances the iterator and returns an array has_iteming the next `N` values.
82+
/// Advances the iterator and returns an array containing the next `N` values.
8383
///
8484
/// If there are not enough elements to fill the array then `Err` is returned
85-
/// has_iteming an iterator over the remaining elements.
85+
/// containing an iterator over the remaining elements.
8686
///
8787
/// # Examples
8888
///
@@ -1327,7 +1327,7 @@ pub trait Iterator {
13271327
/// `take(n)` yields elements until `n` elements are yielded or the end of
13281328
/// the iterator is reached (whichever happens first).
13291329
/// The returned iterator is a prefix of length `n` if the original iterator
1330-
/// has_items at least `n` elements, otherwise it has_items all of the
1330+
/// contains at least `n` elements, otherwise it containss all of the
13311331
/// (fewer than `n`) elements of the original iterator.
13321332
///
13331333
/// # Examples
@@ -3356,7 +3356,7 @@ pub trait Iterator {
33563356
Rev::new(self)
33573357
}
33583358

3359-
/// Converts an iterator of pairs into a pair of has_itemers.
3359+
/// Converts an iterator of pairs into a pair of containsers.
33603360
///
33613361
/// `unzip()` consumes an entire iterator of pairs, producing two
33623362
/// collections: one from the left elements of the pairs, and one
@@ -4062,7 +4062,7 @@ pub trait Iterator {
40624062
}
40634063

40644064
/// Checks if the Iterator has a value.
4065-
/// 'has_items' is short-circuiting; in other words, it will stop processing
4065+
/// 'contains' is short-circuiting; in other words, it will stop processing
40664066
/// as soon as the function finds the item in the Iterator.
40674067
///
40684068
/// Performance:
@@ -4071,28 +4071,28 @@ pub trait Iterator {
40714071
///
40724072
/// Example:
40734073
/// ```
4074-
/// #![feature(iter_has_item)]
4075-
/// assert!(![1i32, 2i32, 3i32].iter().has_item(&4i32));
4076-
/// assert!([Some(2i32), Option::<i32>::None].iter().has_item(&None));
4077-
/// assert!([Some(2i32), Option::<i32>::None].iter().has_item(&Some(2i32)));
4078-
/// assert!(!Vec::<i32>::new().iter().has_item(&1i32));
4079-
/// assert!([1i32, 2i32, 2i32, 3i32].iter().has_item(&2i32));
4074+
/// #![feature(iter_contains)]
4075+
/// assert!(![1i32, 2i32, 3i32].iter().contains(&4i32));
4076+
/// assert!([Some(2i32), Option::<i32>::None].iter().contains(&None));
4077+
/// assert!([Some(2i32), Option::<i32>::None].iter().contains(&Some(2i32)));
4078+
/// assert!(!Vec::<i32>::new().iter().contains(&1i32));
4079+
/// assert!([1i32, 2i32, 2i32, 3i32].iter().contains(&2i32));
40804080
/// #[derive(PartialEq)]
40814081
/// struct Item {
40824082
/// value: i32,
40834083
/// }
4084-
/// assert!([Item { value: 1i32 }, Item { value: 2i32 }].iter().has_item(&Item { value: 2i32 }));
4085-
/// assert!(["a", "b", "c"].iter().has_item(&"b".to_owned()));
4086-
/// assert!(!["a", "b", "c"].iter().has_item(&"d".to_owned()));
4087-
/// assert!(["a", "b", "c"].iter().has_item(&"b"));
4088-
/// assert!(!["a", "b", "c"].iter().has_item(&"d"));
4089-
/// assert!(["a".to_owned(), "b".to_owned(), "c".to_owned()].iter().has_item(&"b"));
4090-
/// assert!(!["a".to_owned(), "b".to_owned(), "c".to_owned()].iter().has_item(&"d"));
4091-
/// assert!((1..1000).has_item(500i32));
4092-
/// ```
4093-
///
4094-
#[unstable(feature = "iter_has_item", reason = "new API", issue = "127494")]
4095-
fn has_item<Q: ?Sized>(&mut self, item: Q) -> bool
4084+
/// assert!([Item { value: 1i32 }, Item { value: 2i32 }].iter().contains(&Item { value: 2i32 }));
4085+
/// assert!(["a", "b", "c"].iter().contains(&"b".to_owned()));
4086+
/// assert!(!["a", "b", "c"].iter().contains(&"d".to_owned()));
4087+
/// assert!(["a", "b", "c"].iter().contains(&"b"));
4088+
/// assert!(!["a", "b", "c"].iter().contains(&"d"));
4089+
/// assert!(["a".to_owned(), "b".to_owned(), "c".to_owned()].iter().contains(&"b"));
4090+
/// assert!(!["a".to_owned(), "b".to_owned(), "c".to_owned()].iter().contains(&"d"));
4091+
/// assert!((1..1000).contains(500i32));
4092+
/// ```
4093+
///
4094+
#[unstable(feature = "iter_contains", reason = "new API", issue = "127494")]
4095+
fn contains<Q: ?Sized>(&mut self, item: Q) -> bool
40964096
where
40974097
Q: PartialEq<Self::Item>,
40984098
Self: Sized,

library/core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
#![feature(ip)]
172172
#![feature(is_ascii_octdigit)]
173173
#![feature(isqrt)]
174-
#![feature(iter_has_item)]
174+
#![feature(iter_contains)]
175175
#![feature(link_cfg)]
176176
#![feature(offset_of_enum)]
177177
#![feature(offset_of_nested)]

library/core/tests/iter/traits/iterator.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -618,34 +618,34 @@ fn test_next_chunk() {
618618
}
619619
#[test]
620620
fn test_happy_path_item_not_in_iterator() {
621-
assert!(![1i32, 2i32, 3i32].iter().has_item(&4i32));
621+
assert!(![1i32, 2i32, 3i32].iter().contains(&4i32));
622622
}
623623

624624
#[test]
625625
fn test_edge_case_handling_none_values() {
626-
assert!([Some(2i32), Option::<i32>::None].iter().has_item(&None));
627-
assert!([Some(2i32), Option::<i32>::None].iter().has_item(&Some(2i32)));
626+
assert!([Some(2i32), Option::<i32>::None].iter().contains(&None));
627+
assert!([Some(2i32), Option::<i32>::None].iter().contains(&Some(2i32)));
628628
}
629629

630630
#[test]
631631
fn test_edge_case_handling_empty_iterator() {
632-
assert!(!Vec::<i32>::new().iter().has_item(&1i32));
632+
assert!(!Vec::<i32>::new().iter().contains(&1i32));
633633
}
634634

635635
#[test]
636636
fn test_edge_case_handling_iterator_with_duplicates() {
637-
assert!([1i32, 2i32, 2i32, 3i32].iter().has_item(&2i32));
637+
assert!([1i32, 2i32, 2i32, 3i32].iter().contains(&2i32));
638638
}
639639

640640
#[test]
641-
/// Tests that short-circuiting works correctly when using `has_item`
641+
/// Tests that short-circuiting works correctly when using `contains`
642642
/// When you run the function, it should move the iterator forward after the first appearance of the item
643643
fn test_short_circuiting() {
644644
let vector: Vec<i32> = vec![1i32, 2i32, 3i32, 1i32, 1i32];
645645
let mut iterator = vector.into_iter();
646-
assert!(iterator.has_item(1i32));
646+
assert!(iterator.contains(1i32));
647647
assert_eq!(iterator.next(), Some(2));
648-
assert!(!iterator.has_item(4i32));
648+
assert!(!iterator.contains(4i32));
649649
assert_eq!(iterator.next(), None);
650650
}
651651

@@ -655,30 +655,30 @@ fn test_edge_case_handling_iterator_with_custom_struct() {
655655
struct Item {
656656
value: i32,
657657
}
658-
assert!([Item { value: 1i32 }, Item { value: 2i32 }].iter().has_item(&Item { value: 2i32 }));
658+
assert!([Item { value: 1i32 }, Item { value: 2i32 }].iter().contains(&Item { value: 2i32 }));
659659
}
660660

661661
#[test]
662-
fn test_str_iterator_has_item_string() {
663-
assert!(["a", "b", "c"].iter().has_item(&"b".to_owned()));
664-
assert!(!["a", "b", "c"].iter().has_item(&"d".to_owned()));
662+
fn test_str_iterator_contains_string() {
663+
assert!(["a", "b", "c"].iter().contains(&"b".to_owned()));
664+
assert!(!["a", "b", "c"].iter().contains(&"d".to_owned()));
665665
}
666666

667667
#[test]
668-
fn test_str_iterator_has_item_string_slice() {
669-
assert!(["a", "b", "c"].iter().has_item(&"b"));
670-
assert!(!["a", "b", "c"].iter().has_item(&"d"));
668+
fn test_str_iterator_contains_string_slice() {
669+
assert!(["a", "b", "c"].iter().contains(&"b"));
670+
assert!(!["a", "b", "c"].iter().contains(&"d"));
671671
}
672672

673673
#[test]
674-
fn test_string_iterator_has_item_str_slice() {
675-
assert!(["a".to_owned(), "b".to_owned(), "c".to_owned()].iter().has_item(&"b"));
676-
assert!(!["a".to_owned(), "b".to_owned(), "c".to_owned()].iter().has_item(&"d"));
674+
fn test_string_iterator_contains_str_slice() {
675+
assert!(["a".to_owned(), "b".to_owned(), "c".to_owned()].iter().contains(&"b"));
676+
assert!(!["a".to_owned(), "b".to_owned(), "c".to_owned()].iter().contains(&"d"));
677677
}
678678

679679
#[test]
680680
fn test_edge_case_handling_iterator_with_large_number_of_elements() {
681-
assert!((1..1000).has_item(500i32));
681+
assert!((1..1000).contains(500i32));
682682
}
683683

684684
// just tests by whether or not this compiles

library/core/tests/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
#![feature(const_mut_refs)]
9090
#![feature(const_pin)]
9191
#![feature(const_waker)]
92-
#![feature(iter_has_item)]
92+
#![feature(iter_contains)]
9393
#![feature(never_type)]
9494
#![feature(unwrap_infallible)]
9595
#![feature(pointer_is_aligned_to)]

0 commit comments

Comments
 (0)