about summary refs log tree commit diff
path: root/library
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-10-01 18:42:35 +0200
committerGitHub <noreply@github.com>2025-10-01 18:42:35 +0200
commit1feb547a52113ffbea4cd720f01e3ef1ec922607 (patch)
tree7a716f43d49f2f11a394a55e482f7123d2adcfaa /library
parente40e50ed49a1f7e8d30e3d9b5449425528906c94 (diff)
parent50398e2e7505779323e5371b1905c4ad56a29097 (diff)
downloadrust-1feb547a52113ffbea4cd720f01e3ef1ec922607.tar.gz
rust-1feb547a52113ffbea4cd720f01e3ef1ec922607.zip
Rollup merge of #147195 - hkBst:repeat-3, r=Mark-Simulacrum
iter repeat: add tests for new count and last behavior

Tests for https://github.com/rust-lang/rust/pull/146410
Diffstat (limited to 'library')
-rw-r--r--library/coretests/tests/iter/sources.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/library/coretests/tests/iter/sources.rs b/library/coretests/tests/iter/sources.rs
index 506febaa056..5a391cb6775 100644
--- a/library/coretests/tests/iter/sources.rs
+++ b/library/coretests/tests/iter/sources.rs
@@ -31,6 +31,17 @@ fn test_repeat_take_collect() {
 }
 
 #[test]
+#[should_panic = "iterator is infinite"]
+fn test_repeat_count() {
+    repeat(42).count();
+}
+
+#[test]
+fn test_repeat_last() {
+    assert_eq!(repeat(42).last(), Some(42));
+}
+
+#[test]
 fn test_repeat_with() {
     #[derive(PartialEq, Debug)]
     struct NotClone(usize);