Add support for suggesting as_ref to Result accesses
This commit is contained in:
parent
4b0963653e
commit
1cc42ea675
4 changed files with 54 additions and 3 deletions
|
|
@ -18,4 +18,22 @@ impl LipogramCorpora {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct LipogramCorpora2 {
|
||||
selections: Vec<(char, Result<String, String>)>,
|
||||
}
|
||||
|
||||
impl LipogramCorpora2 {
|
||||
pub fn validate_all(&mut self) -> Result<(), char> {
|
||||
for selection in &self.selections {
|
||||
if selection.1.is_ok() {
|
||||
if selection.1.as_ref().unwrap().contains(selection.0) {
|
||||
//~^ ERROR cannot move out of borrowed content
|
||||
return Err(selection.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -18,4 +18,22 @@ impl LipogramCorpora {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct LipogramCorpora2 {
|
||||
selections: Vec<(char, Result<String, String>)>,
|
||||
}
|
||||
|
||||
impl LipogramCorpora2 {
|
||||
pub fn validate_all(&mut self) -> Result<(), char> {
|
||||
for selection in &self.selections {
|
||||
if selection.1.is_ok() {
|
||||
if selection.1.unwrap().contains(selection.0) {
|
||||
//~^ ERROR cannot move out of borrowed content
|
||||
return Err(selection.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,15 @@ LL | if selection.1.unwrap().contains(selection.0) {
|
|||
| cannot move out of borrowed content
|
||||
| help: consider borrowing the `Option`'s content: `selection.1.as_ref()`
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/option-content-move.rs:29:20
|
||||
|
|
||||
LL | if selection.1.unwrap().contains(selection.0) {
|
||||
| ^^^^^^^^^^^
|
||||
| |
|
||||
| cannot move out of borrowed content
|
||||
| help: consider borrowing the `Result`'s content: `selection.1.as_ref()`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0507`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue