Skip to content

Commit 66c55b2

Browse files
committed
renamed contain to has_item
1 parent cd839b8 commit 66c55b2

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: 26 additions & 26 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 containing the next `N` values.
82+
/// Advances the iterator and returns an array has_iteming the next `N` values.
8383
///
8484
/// If there are not enough elements to fill the array then `Err` is returned
85-
/// containing an iterator over the remaining elements.
85+
/// has_iteming 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-
/// contains at least `n` elements, otherwise it contains all of the
1330+
/// has_items at least `n` elements, otherwise it has_items 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 containers.
3359+
/// Converts an iterator of pairs into a pair of has_itemers.
33603360
///
33613361
/// `unzip()` consumes an entire iterator of pairs, producing two
33623362
/// collections: one from the left elements of the pairs, and one
@@ -4061,38 +4061,38 @@ pub trait Iterator {
40614061
unreachable!("Always specialized");
40624062
}
40634063

4064-
/// Checks if the Iterator contains the value.
4065-
/// 'contains' is short-circuiting; in other words, it will stop processing
4066-
/// as soon as the closure returns `true`.
4064+
/// Checks if the Iterator has a value.
4065+
/// 'has_items' is short-circuiting; in other words, it will stop processing
4066+
/// as soon as the function finds the item in the Iterator.
40674067
///
40684068
/// Performance:
40694069
/// This method checks the whole iterator, which takes O(n) time.
4070-
/// If the iterator is sorted, or a hash map please use the appropriate method.
4070+
/// If the iterator is sorted, or a hash map please use the appropriate method instead.
40714071
///
40724072
/// Example:
40734073
/// ```
4074-
/// #![feature(contains)]
4075-
/// assert!(![1i32, 2i32, 3i32].iter().contain(&4i32));
4076-
/// assert!([Some(2i32), Option::<i32>::None].iter().contain(&None));
4077-
/// assert!([Some(2i32), Option::<i32>::None].iter().contain(&Some(2i32)));
4078-
/// assert!(!Vec::<i32>::new().iter().contain(&1i32));
4079-
/// assert!([1i32, 2i32, 2i32, 3i32].iter().contain(&2i32));
4074+
/// #![feature(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));
40804080
/// #[derive(PartialEq)]
40814081
/// struct Item {
40824082
/// value: i32,
40834083
/// }
4084-
/// assert!([Item { value: 1i32 }, Item { value: 2i32 }].iter().contain(&Item { value: 2i32 }));
4085-
/// assert!(["a", "b", "c"].iter().contain(&"b".to_owned()));
4086-
/// assert!(!["a", "b", "c"].iter().contain(&"d".to_owned()));
4087-
/// assert!(["a", "b", "c"].iter().contain(&"b"));
4088-
/// assert!(!["a", "b", "c"].iter().contain(&"d"));
4089-
/// assert!(["a".to_owned(), "b".to_owned(), "c".to_owned()].iter().contain(&"b"));
4090-
/// assert!(!["a".to_owned(), "b".to_owned(), "c".to_owned()].iter().contain(&"d"));
4091-
/// assert!((1..1000).contain(500i32));
4092-
/// ```
4093-
///
4094-
#[unstable(feature = "contains", reason = "new API", issue = "127494")]
4095-
fn contain<Q: ?Sized>(&mut self, item: Q) -> bool
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 = "has_item", reason = "new API", issue = "127494")]
4095+
fn has_item<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
@@ -165,9 +165,9 @@
165165
#![feature(const_unicode_case_lookup)]
166166
#![feature(const_unsafecell_get_mut)]
167167
#![feature(const_waker)]
168-
#![feature(contains)]
169168
#![feature(coverage_attribute)]
170169
#![feature(duration_consts_float)]
170+
#![feature(has_item)]
171171
#![feature(internal_impls_macro)]
172172
#![feature(ip)]
173173
#![feature(is_ascii_octdigit)]

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

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

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

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

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

640640
#[test]
@@ -643,30 +643,30 @@ fn test_edge_case_handling_iterator_with_custom_struct() {
643643
struct Item {
644644
value: i32,
645645
}
646-
assert!([Item { value: 1i32 }, Item { value: 2i32 }].iter().contain(&Item { value: 2i32 }));
646+
assert!([Item { value: 1i32 }, Item { value: 2i32 }].iter().has_item(&Item { value: 2i32 }));
647647
}
648648

649649
#[test]
650-
fn test_str_iterator_contain_string() {
651-
assert!(["a", "b", "c"].iter().contain(&"b".to_owned()));
652-
assert!(!["a", "b", "c"].iter().contain(&"d".to_owned()));
650+
fn test_str_iterator_has_item_string() {
651+
assert!(["a", "b", "c"].iter().has_item(&"b".to_owned()));
652+
assert!(!["a", "b", "c"].iter().has_item(&"d".to_owned()));
653653
}
654654

655655
#[test]
656-
fn test_str_iterator_contain_string_slice() {
657-
assert!(["a", "b", "c"].iter().contain(&"b"));
658-
assert!(!["a", "b", "c"].iter().contain(&"d"));
656+
fn test_str_iterator_has_item_string_slice() {
657+
assert!(["a", "b", "c"].iter().has_item(&"b"));
658+
assert!(!["a", "b", "c"].iter().has_item(&"d"));
659659
}
660660

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

667667
#[test]
668668
fn test_edge_case_handling_iterator_with_large_number_of_elements() {
669-
assert!((1..1000).contain(500i32));
669+
assert!((1..1000).has_item(500i32));
670670
}
671671

672672
// 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(contains)]
92+
#![feature(has_item)]
9393
#![feature(never_type)]
9494
#![feature(unwrap_infallible)]
9595
#![feature(pointer_is_aligned_to)]

0 commit comments

Comments
 (0)