Skip to content

Commit e5e5592

Browse files
committed
run cargo fmt
1 parent e24ae9c commit e5e5592

File tree

3 files changed

+52
-30
lines changed

3 files changed

+52
-30
lines changed

src/build.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::vec::Vec;
1010
pub struct CratePatch {
1111
pub name: String,
1212
pub uri: String,
13-
pub branch: String
13+
pub branch: String,
1414
}
1515

1616
/// Directory in the [`Workspace`](struct.Workspace.html) where builds can be executed.
@@ -33,7 +33,6 @@ pub struct Builder<'a> {
3333
}
3434

3535
impl<'a> Builder<'a> {
36-
3736
/// Add a patch to this build.
3837
/// Patches get added to the crate's Cargo.toml in the `patch.crates-io` table.
3938
/// # Example
@@ -56,7 +55,7 @@ impl<'a> Builder<'a> {
5655
/// # Ok(())
5756
/// # }
5857
pub fn patch_with_git(mut self, name: String, uri: String, branch: String) -> Self {
59-
self.patches.push(CratePatch { name, uri, branch});
58+
self.patches.push(CratePatch { name, uri, branch });
6059
self
6160
}
6261

@@ -84,7 +83,8 @@ impl<'a> Builder<'a> {
8483
/// # Ok(())
8584
/// # }
8685
pub fn run<R, F: FnOnce(&Build) -> Result<R, Error>>(self, f: F) -> Result<R, Error> {
87-
self.build_dir.run(self.toolchain, self.krate, self.sandbox, self.patches, f)
86+
self.build_dir
87+
.run(self.toolchain, self.krate, self.sandbox, self.patches, f)
8888
}
8989
}
9090

@@ -117,13 +117,18 @@ impl BuildDirectory {
117117
/// # Ok(())
118118
/// # }
119119
/// ```
120-
pub fn build<'a>(&'a mut self,
120+
pub fn build<'a>(
121+
&'a mut self,
121122
toolchain: &'a Toolchain,
122123
krate: &'a Crate,
123124
sandbox: SandboxBuilder,
124125
) -> Builder {
125126
Builder {
126-
build_dir: self, toolchain, krate, sandbox, patches: Vec::new()
127+
build_dir: self,
128+
toolchain,
129+
krate,
130+
sandbox,
131+
patches: Vec::new(),
127132
}
128133
}
129134

src/prepare.rs

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::cmd::Command;
2-
use crate::{Crate, Toolchain, Workspace, build::CratePatch};
2+
use crate::{build::CratePatch, Crate, Toolchain, Workspace};
33
use failure::{Error, Fail, ResultExt};
44
use log::info;
55
use std::path::Path;
@@ -14,7 +14,7 @@ pub(crate) struct Prepare<'a> {
1414
krate: &'a Crate,
1515
source_dir: &'a Path,
1616
lockfile_captured: bool,
17-
patches: Vec<CratePatch>
17+
patches: Vec<CratePatch>,
1818
}
1919

2020
impl<'a> Prepare<'a> {
@@ -23,7 +23,7 @@ impl<'a> Prepare<'a> {
2323
toolchain: &'a Toolchain,
2424
krate: &'a Crate,
2525
source_dir: &'a Path,
26-
patches: Vec<CratePatch>
26+
patches: Vec<CratePatch>,
2727
) -> Self {
2828
Self {
2929
workspace,
@@ -150,15 +150,24 @@ pub struct TomlTweaker<'a> {
150150
}
151151

152152
impl<'a> TomlTweaker<'a> {
153-
pub fn new(krate: &'a Crate, cargo_toml: &'a Path, patches: &[CratePatch]) -> Result<Self, Error> {
153+
pub fn new(
154+
krate: &'a Crate,
155+
cargo_toml: &'a Path,
156+
patches: &[CratePatch],
157+
) -> Result<Self, Error> {
154158
let toml_content = ::std::fs::read_to_string(cargo_toml)
155159
.with_context(|_| PrepareError::MissingCargoToml)?;
156160
let table: Table =
157161
toml::from_str(&toml_content).with_context(|_| PrepareError::InvalidCargoTomlSyntax)?;
158162

159163
let dir = cargo_toml.parent();
160164

161-
Ok(TomlTweaker { krate, table, dir, patches: patches.to_vec() })
165+
Ok(TomlTweaker {
166+
krate,
167+
table,
168+
dir,
169+
patches: patches.to_vec(),
170+
})
162171
}
163172

164173
#[cfg(test)]
@@ -287,16 +296,20 @@ impl<'a> TomlTweaker<'a> {
287296
let patch_table = match patch_table {
288297
Some(ref mut pt) => pt,
289298
None => {
290-
self.table.insert("patch".to_string(), Value::Table(Table::new()));
299+
self.table
300+
.insert("patch".to_string(), Value::Table(Table::new()));
291301
self.table.get_mut("patch").unwrap()
292-
},
302+
}
293303
};
294304

295305
let mut cratesio_table = patch_table.get_mut("crates-io");
296306
let cratesio_table = match cratesio_table {
297307
Some(ref mut cio) => cio,
298308
None => {
299-
patch_table.as_table_mut().unwrap().insert("crates-io".to_string(), Value::Table(Table::new()));
309+
patch_table
310+
.as_table_mut()
311+
.unwrap()
312+
.insert("crates-io".to_string(), Value::Table(Table::new()));
300313
patch_table.get_mut("crates-io").unwrap()
301314
}
302315
};
@@ -305,7 +318,10 @@ impl<'a> TomlTweaker<'a> {
305318
let mut table = Table::new();
306319
table.insert("git".into(), Value::String(patch.uri));
307320
table.insert("branch".into(), Value::String(patch.branch));
308-
cratesio_table.as_table_mut().unwrap().insert(patch.name, Value::Table(table));
321+
cratesio_table
322+
.as_table_mut()
323+
.unwrap()
324+
.insert(patch.name, Value::Table(table));
309325
}
310326
}
311327
}
@@ -365,8 +381,8 @@ pub enum PrepareError {
365381
#[cfg(test)]
366382
mod tests {
367383
use super::TomlTweaker;
368-
use crate::crates::Crate;
369384
use crate::build::CratePatch;
385+
use crate::crates::Crate;
370386
use toml::{self, Value};
371387

372388
#[test]
@@ -392,7 +408,8 @@ mod tests {
392408

393409
let krate = Crate::local("/dev/null".as_ref());
394410
let patches: Vec<CratePatch> = Vec::new();
395-
let mut tweaker = TomlTweaker::new_with_table(&krate, toml.as_table().unwrap().clone(), &patches);
411+
let mut tweaker =
412+
TomlTweaker::new_with_table(&krate, toml.as_table().unwrap().clone(), &patches);
396413
tweaker.tweak();
397414

398415
assert_eq!(Value::Table(tweaker.table), result);
@@ -442,7 +459,8 @@ mod tests {
442459

443460
let krate = Crate::local("/dev/null".as_ref());
444461
let patches: Vec<CratePatch> = Vec::new();
445-
let mut tweaker = TomlTweaker::new_with_table(&krate, toml.as_table().unwrap().clone(), &patches);
462+
let mut tweaker =
463+
TomlTweaker::new_with_table(&krate, toml.as_table().unwrap().clone(), &patches);
446464
tweaker.tweak();
447465

448466
assert_eq!(Value::Table(tweaker.table), result);
@@ -488,14 +506,13 @@ mod tests {
488506
};
489507

490508
let krate = Crate::local("/dev/null".as_ref());
491-
let patches = vec![
492-
CratePatch {
493-
name: "quux".into(),
494-
uri: "https://git.example.com/quux".into(),
495-
branch: "dev".into(),
496-
}
497-
];
498-
let mut tweaker = TomlTweaker::new_with_table(&krate, toml.as_table().unwrap().clone(), &patches);
509+
let patches = vec![CratePatch {
510+
name: "quux".into(),
511+
uri: "https://git.example.com/quux".into(),
512+
branch: "dev".into(),
513+
}];
514+
let mut tweaker =
515+
TomlTweaker::new_with_table(&krate, toml.as_table().unwrap().clone(), &patches);
499516
tweaker.tweak();
500517

501518
assert_eq!(Value::Table(tweaker.table), result);

tests/integration/crates_git.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ fn test_fetch() -> Result<(), Error> {
1818
let cloned_commit = || -> Result<String, Error> {
1919
let mut dir = workspace.build_dir("integration-crates_git-test_fetch");
2020
dir.purge()?;
21-
Ok(
22-
dir.build(&toolchain, &krate, SandboxBuilder::new()).run(|build| {
21+
Ok(dir
22+
.build(&toolchain, &krate, SandboxBuilder::new())
23+
.run(|build| {
2324
Ok(Command::new(&workspace, "git")
2425
.args(&["rev-parse", "HEAD"])
2526
.cd(build.host_source_dir())
2627
.run_capture()?
2728
.stdout_lines()[0]
2829
.to_string())
29-
})?,
30-
)
30+
})?)
3131
};
3232

3333
// Check if the initial commit was fetched

0 commit comments

Comments
 (0)