889: Fix clippy warnings r=MarinPostma a=TaKO8Ki

Good day!

Since `cargo clippy` showed two warnings like the following, I've fixed them. This is a small PR.

```sh
warning: use of `ok_or` followed by a function call
   --> meilisearch-core/src/database.rs:185:18
    |
185 |                 .ok_or(Error::VersionMismatch("bad VERSION file".to_string()))?;
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `ok_or_else(|| Error::VersionMismatch("bad VERSION file".to_string()))`
    |
    = note: `#[warn(clippy::or_fun_call)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call

warning: useless use of `format!`
   --> meilisearch-core/src/database.rs:208:59
    |
208 |                         return Err(Error::VersionMismatch(format!("<0.12.0")));
    |                                                           ^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"<0.12.0".to_string()`
    |
    = note: `#[warn(clippy::useless_format)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format

warning: 2 warnings emitted
```

Co-authored-by: Takayuki Maeda <41065217+TaKO8Ki@users.noreply.github.com>
This commit is contained in:
bors[bot] 2020-07-29 11:40:08 +00:00 committed by GitHub
commit fb69769991
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -182,7 +182,7 @@ fn version_guard(path: &Path, create: bool) -> MResult<()> {
let version = re let version = re
.captures_iter(&version) .captures_iter(&version)
.next() .next()
.ok_or(Error::VersionMismatch("bad VERSION file".to_string()))?; .ok_or_else(|| Error::VersionMismatch("bad VERSION file".to_string()))?;
// the first is always the complete match, safe to unwrap because we have a match // the first is always the complete match, safe to unwrap because we have a match
let version_major = version.get(1).unwrap().as_str(); let version_major = version.get(1).unwrap().as_str();
let version_minor = version.get(2).unwrap().as_str(); let version_minor = version.get(2).unwrap().as_str();
@ -205,7 +205,7 @@ fn version_guard(path: &Path, create: bool) -> MResult<()> {
} else { } else {
// when no version file is found and we were not told to create one, this // when no version file is found and we were not told to create one, this
// means that the version is inferior to the one this feature was added in. // means that the version is inferior to the one this feature was added in.
return Err(Error::VersionMismatch(format!("<0.12.0"))); return Err(Error::VersionMismatch("<0.12.0".to_string()));
} }
} }
_ => return Err(error.into()) _ => return Err(error.into())