test: add test cases for str
This commit is contained in:
parent
6f6dd880bc
commit
e36c7d55b6
@ -224,15 +224,42 @@ mod issue_11910 {
|
|||||||
fn bar(&self, _: bool) {}
|
fn bar(&self, _: bool) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_then() {
|
fn test_normal_for_iter() {
|
||||||
|
let v = vec![3, 2, 1, 0, -1, -2, -3];
|
||||||
|
let _ = !v.iter().any(|x| *x == 42);
|
||||||
|
Foo.bar(!v.iter().any(|x| *x == 42));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_then_for_iter() {
|
||||||
let v = vec![3, 2, 1, 0, -1, -2, -3];
|
let v = vec![3, 2, 1, 0, -1, -2, -3];
|
||||||
(!v.iter().any(|x| *x == 42)).then(computations);
|
(!v.iter().any(|x| *x == 42)).then(computations);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_then_some() {
|
fn test_then_some_for_iter() {
|
||||||
let v = vec![3, 2, 1, 0, -1, -2, -3];
|
let v = vec![3, 2, 1, 0, -1, -2, -3];
|
||||||
(!v.iter().any(|x| *x == 42)).then_some(0);
|
(!v.iter().any(|x| *x == 42)).then_some(0);
|
||||||
|
}
|
||||||
|
|
||||||
Foo.bar(!v.iter().any(|x| *x == 42));
|
fn test_normal_for_str() {
|
||||||
|
let s = "hello";
|
||||||
|
let _ = !s.contains("world");
|
||||||
|
Foo.bar(!s.contains("world"));
|
||||||
|
let s = String::from("hello");
|
||||||
|
let _ = !s.contains("world");
|
||||||
|
Foo.bar(!s.contains("world"));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_then_for_str() {
|
||||||
|
let s = "hello";
|
||||||
|
let _ = (!s.contains("world")).then(computations);
|
||||||
|
let s = String::from("hello");
|
||||||
|
let _ = (!s.contains("world")).then(computations);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_then_some_for_str() {
|
||||||
|
let s = "hello";
|
||||||
|
let _ = (!s.contains("world")).then_some(0);
|
||||||
|
let s = String::from("hello");
|
||||||
|
let _ = (!s.contains("world")).then_some(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,15 +230,42 @@ impl Foo {
|
|||||||
fn bar(&self, _: bool) {}
|
fn bar(&self, _: bool) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_then() {
|
fn test_normal_for_iter() {
|
||||||
|
let v = vec![3, 2, 1, 0, -1, -2, -3];
|
||||||
|
let _ = v.iter().find(|x| **x == 42).is_none();
|
||||||
|
Foo.bar(v.iter().find(|x| **x == 42).is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_then_for_iter() {
|
||||||
let v = vec![3, 2, 1, 0, -1, -2, -3];
|
let v = vec![3, 2, 1, 0, -1, -2, -3];
|
||||||
v.iter().find(|x| **x == 42).is_none().then(computations);
|
v.iter().find(|x| **x == 42).is_none().then(computations);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_then_some() {
|
fn test_then_some_for_iter() {
|
||||||
let v = vec![3, 2, 1, 0, -1, -2, -3];
|
let v = vec![3, 2, 1, 0, -1, -2, -3];
|
||||||
v.iter().find(|x| **x == 42).is_none().then_some(0);
|
v.iter().find(|x| **x == 42).is_none().then_some(0);
|
||||||
|
}
|
||||||
|
|
||||||
Foo.bar(v.iter().find(|x| **x == 42).is_none());
|
fn test_normal_for_str() {
|
||||||
|
let s = "hello";
|
||||||
|
let _ = s.find("world").is_none();
|
||||||
|
Foo.bar(s.find("world").is_none());
|
||||||
|
let s = String::from("hello");
|
||||||
|
let _ = s.find("world").is_none();
|
||||||
|
Foo.bar(s.find("world").is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_then_for_str() {
|
||||||
|
let s = "hello";
|
||||||
|
let _ = s.find("world").is_none().then(computations);
|
||||||
|
let s = String::from("hello");
|
||||||
|
let _ = s.find("world").is_none().then(computations);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_then_some_for_str() {
|
||||||
|
let s = "hello";
|
||||||
|
let _ = s.find("world").is_none().then_some(0);
|
||||||
|
let s = String::from("hello");
|
||||||
|
let _ = s.find("world").is_none().then_some(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,22 +283,76 @@ LL | let _ = v.iter().find(|fp| test_u32_2(*fp.field)).is_none();
|
|||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|fp| test_u32_2(*fp.field))`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|fp| test_u32_2(*fp.field))`
|
||||||
|
|
||||||
error: called `is_none()` after searching an `Iterator` with `find`
|
error: called `is_none()` after searching an `Iterator` with `find`
|
||||||
--> $DIR/search_is_some_fixable_none.rs:235:9
|
--> $DIR/search_is_some_fixable_none.rs:235:17
|
||||||
|
|
|
||||||
|
LL | let _ = v.iter().find(|x| **x == 42).is_none();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x| *x == 42)`
|
||||||
|
|
||||||
|
error: called `is_none()` after searching an `Iterator` with `find`
|
||||||
|
--> $DIR/search_is_some_fixable_none.rs:236:17
|
||||||
|
|
|
||||||
|
LL | Foo.bar(v.iter().find(|x| **x == 42).is_none());
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x| *x == 42)`
|
||||||
|
|
||||||
|
error: called `is_none()` after searching an `Iterator` with `find`
|
||||||
|
--> $DIR/search_is_some_fixable_none.rs:241:9
|
||||||
|
|
|
|
||||||
LL | v.iter().find(|x| **x == 42).is_none().then(computations);
|
LL | v.iter().find(|x| **x == 42).is_none().then(computations);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(!v.iter().any(|x| *x == 42))`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(!v.iter().any(|x| *x == 42))`
|
||||||
|
|
||||||
error: called `is_none()` after searching an `Iterator` with `find`
|
error: called `is_none()` after searching an `Iterator` with `find`
|
||||||
--> $DIR/search_is_some_fixable_none.rs:240:9
|
--> $DIR/search_is_some_fixable_none.rs:246:9
|
||||||
|
|
|
|
||||||
LL | v.iter().find(|x| **x == 42).is_none().then_some(0);
|
LL | v.iter().find(|x| **x == 42).is_none().then_some(0);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(!v.iter().any(|x| *x == 42))`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(!v.iter().any(|x| *x == 42))`
|
||||||
|
|
||||||
error: called `is_none()` after searching an `Iterator` with `find`
|
error: called `is_none()` after calling `find()` on a string
|
||||||
--> $DIR/search_is_some_fixable_none.rs:242:17
|
--> $DIR/search_is_some_fixable_none.rs:251:17
|
||||||
|
|
|
|
||||||
LL | Foo.bar(v.iter().find(|x| **x == 42).is_none());
|
LL | let _ = s.find("world").is_none();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x| *x == 42)`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s.contains("world")`
|
||||||
|
|
||||||
error: aborting due to 46 previous errors
|
error: called `is_none()` after calling `find()` on a string
|
||||||
|
--> $DIR/search_is_some_fixable_none.rs:252:17
|
||||||
|
|
|
||||||
|
LL | Foo.bar(s.find("world").is_none());
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s.contains("world")`
|
||||||
|
|
||||||
|
error: called `is_none()` after calling `find()` on a string
|
||||||
|
--> $DIR/search_is_some_fixable_none.rs:254:17
|
||||||
|
|
|
||||||
|
LL | let _ = s.find("world").is_none();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s.contains("world")`
|
||||||
|
|
||||||
|
error: called `is_none()` after calling `find()` on a string
|
||||||
|
--> $DIR/search_is_some_fixable_none.rs:255:17
|
||||||
|
|
|
||||||
|
LL | Foo.bar(s.find("world").is_none());
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s.contains("world")`
|
||||||
|
|
||||||
|
error: called `is_none()` after calling `find()` on a string
|
||||||
|
--> $DIR/search_is_some_fixable_none.rs:260:17
|
||||||
|
|
|
||||||
|
LL | let _ = s.find("world").is_none().then(computations);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(!s.contains("world"))`
|
||||||
|
|
||||||
|
error: called `is_none()` after calling `find()` on a string
|
||||||
|
--> $DIR/search_is_some_fixable_none.rs:262:17
|
||||||
|
|
|
||||||
|
LL | let _ = s.find("world").is_none().then(computations);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(!s.contains("world"))`
|
||||||
|
|
||||||
|
error: called `is_none()` after calling `find()` on a string
|
||||||
|
--> $DIR/search_is_some_fixable_none.rs:267:17
|
||||||
|
|
|
||||||
|
LL | let _ = s.find("world").is_none().then_some(0);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(!s.contains("world"))`
|
||||||
|
|
||||||
|
error: called `is_none()` after calling `find()` on a string
|
||||||
|
--> $DIR/search_is_some_fixable_none.rs:269:17
|
||||||
|
|
|
||||||
|
LL | let _ = s.find("world").is_none().then_some(0);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(!s.contains("world"))`
|
||||||
|
|
||||||
|
error: aborting due to 55 previous errors
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user