We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e83666f commit 1f6f917Copy full SHA for 1f6f917
library/alloc/tests/string.rs
@@ -1,6 +1,7 @@
1
use std::borrow::Cow;
2
use std::collections::TryReserveError::*;
3
use std::ops::Bound::*;
4
+use std::panic;
5
6
pub trait IntoCow<'a, B: ?Sized>
7
where
@@ -378,6 +379,20 @@ fn test_retain() {
378
379
380
s.retain(|_| false);
381
assert_eq!(s, "");
382
+
383
+ let mut s = String::from("0è0");
384
+ let _ = panic::catch_unwind(panic::AssertUnwindSafe(|| {
385
+ let mut count = 0;
386
+ s.retain(|_| {
387
+ count += 1;
388
+ match count {
389
+ 1 => false,
390
+ 2 => true,
391
+ _ => panic!(),
392
+ }
393
+ });
394
+ }));
395
+ assert!(std::str::from_utf8(s.as_bytes()).is_ok());
396
}
397
398
#[test]
0 commit comments