Avoid allocating the nix options twide.
This commit is contained in:
parent
9eb15be5ce
commit
f584494464
1 changed files with 5 additions and 10 deletions
15
src/main.rs
15
src/main.rs
|
|
@ -1,6 +1,7 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
|
use std::mem;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::{self, ExitCode};
|
use std::process::{self, ExitCode};
|
||||||
|
|
||||||
|
|
@ -137,18 +138,12 @@ fn go(args: Args) -> Result<()> {
|
||||||
nix_options,
|
nix_options,
|
||||||
} = args;
|
} = args;
|
||||||
|
|
||||||
let nix_options = NixOptions::new(nix_options.map_or(Vec::new(), |vals| {
|
let nix_options = NixOptions::new(nix_options.map_or(Vec::new(), |mut vals| {
|
||||||
vals.chunks(2)
|
vals.chunks_mut(2)
|
||||||
.map(|slice| {
|
.map(|slice| {
|
||||||
(
|
(
|
||||||
slice
|
mem::take(slice.get_mut(0).expect("Error parsing nix-option values")),
|
||||||
.get(0)
|
mem::take(slice.get_mut(1).expect("Error parsing nix-option values")),
|
||||||
.expect("Error parsing nix-option values")
|
|
||||||
.to_owned(),
|
|
||||||
slice
|
|
||||||
.get(1)
|
|
||||||
.expect("Error parsing nix-option values")
|
|
||||||
.to_owned(),
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue