diff options
author | Nora Widdecke <nora@sequoia-pgp.org> | 2021-11-22 20:41:01 +0100 |
---|---|---|
committer | Nora Widdecke <nora@sequoia-pgp.org> | 2021-11-29 11:53:56 +0100 |
commit | 58946b2da1bf12c42854c03e67d6ba0a540ce317 (patch) | |
tree | 2c8bc477410b0721af912c340f9f21eca204592d /openpgp-ffi/tests | |
parent | 307a6d739df7728b9676b51743edc42ef45f7379 (diff) |
Use std::mem::take instead of std::mem::replace, for clarity.
- Replace
let bar = std::mem::replace(&foo, Default::Default());
with
let bar = std::mem::take(&foo);
The new version seems a little clearer.
- Found by clippy:
https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default
Diffstat (limited to 'openpgp-ffi/tests')
-rw-r--r-- | openpgp-ffi/tests/c-tests.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/openpgp-ffi/tests/c-tests.rs b/openpgp-ffi/tests/c-tests.rs index a93653db..ecd68bcf 100644 --- a/openpgp-ffi/tests/c-tests.rs +++ b/openpgp-ffi/tests/c-tests.rs @@ -8,7 +8,6 @@ use std::io::{self, BufRead, Write}; use std::path::{Path, PathBuf}; use std::process::Command; use std::str::FromStr; -use std::mem::replace; /// Hooks into Rust's test system to extract, compile and run c tests. #[test] @@ -162,7 +161,7 @@ fn for_all_tests<F>(path: &Path, mut fun: F) if let Some(name) = exported_function_name(&line) { if !test.is_empty() { - fun(path, test_starts_at, name, replace(&mut test, vec![]), + fun(path, test_starts_at, name, std::mem::take(&mut test), run)?; test.clear(); } @@ -178,7 +177,7 @@ fn for_all_tests<F>(path: &Path, mut fun: F) path.file_stem().unwrap().to_string_lossy(), lineno); // XXX: nicer to point to the top - fun(path, test_starts_at, &name, replace(&mut test, Vec::new()), + fun(path, test_starts_at, &name, std::mem::take(&mut test), run)?; test.clear(); in_test = false; |