Skip to content

Commit e24ae9c

Browse files
committed
refactor cratepatch out of the interface
1 parent f0786a7 commit e24ae9c

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

src/build.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ use remove_dir_all::remove_dir_all;
66
use std::path::PathBuf;
77
use std::vec::Vec;
88

9-
/// Holds info for a patch to be added to a crate's Cargo.toml
109
#[derive(Clone)]
1110
pub struct CratePatch {
12-
/// Crate name to patch
1311
pub name: String,
14-
/// URL of the git repo
1512
pub uri: String,
16-
/// Branch of the git repo
1713
pub branch: String
1814
}
1915

@@ -43,25 +39,24 @@ impl<'a> Builder<'a> {
4339
/// # Example
4440
///
4541
/// ```no_run
46-
/// # use rustwide::{WorkspaceBuilder, Toolchain, Crate, CratePatch, cmd::SandboxBuilder};
42+
/// # use rustwide::{WorkspaceBuilder, Toolchain, Crate, cmd::SandboxBuilder};
4743
/// # use std::error::Error;
4844
/// # fn main() -> Result<(), Box<dyn Error>> {
4945
/// # let workspace = WorkspaceBuilder::new("".as_ref(), "").init()?;
5046
/// # let toolchain = Toolchain::Dist { name: "".into() };
5147
/// # let krate = Crate::local("".as_ref());
5248
/// # let sandbox = SandboxBuilder::new();
53-
/// let crate_patch = CratePatch { name: "bar".into(), uri: "https://github.com/foo/bar".into(), branch: "baz".into() };
5449
/// let mut build_dir = workspace.build_dir("foo");
5550
/// build_dir.build(&toolchain, &krate, sandbox)
56-
/// .patch(crate_patch)
51+
/// .patch_with_git("bar".into(), "https://github.com/foo/bar".into(), "baz".into())
5752
/// .run(|build| {
5853
/// build.cargo().args(&["test", "--all"]).run()?;
5954
/// Ok(())
6055
/// })?;
6156
/// # Ok(())
6257
/// # }
63-
pub fn patch(mut self, patch: CratePatch) -> Self {
64-
self.patches.push(patch);
58+
pub fn patch_with_git(mut self, name: String, uri: String, branch: String) -> Self {
59+
self.patches.push(CratePatch { name, uri, branch});
6560
self
6661
}
6762

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ mod tools;
2929
mod utils;
3030
mod workspace;
3131

32-
pub use crate::build::{Build, BuildDirectory, CratePatch};
32+
pub use crate::build::{Build, BuildDirectory};
3333
pub use crate::crates::Crate;
3434
pub use crate::prepare::PrepareError;
3535
pub use crate::toolchain::Toolchain;

src/prepare.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::cmd::Command;
2-
use crate::{Crate, Toolchain, CratePatch, Workspace};
2+
use crate::{Crate, Toolchain, Workspace, build::CratePatch};
33
use failure::{Error, Fail, ResultExt};
44
use log::info;
55
use std::path::Path;
@@ -365,7 +365,8 @@ pub enum PrepareError {
365365
#[cfg(test)]
366366
mod tests {
367367
use super::TomlTweaker;
368-
use crate::{CratePatch, crates::Crate};
368+
use crate::crates::Crate;
369+
use crate::build::CratePatch;
369370
use toml::{self, Value};
370371

371372
#[test]

0 commit comments

Comments
 (0)