@@ -6,14 +6,10 @@ use remove_dir_all::remove_dir_all;
6
6
use std:: path:: PathBuf ;
7
7
use std:: vec:: Vec ;
8
8
9
- /// Holds info for a patch to be added to a crate's Cargo.toml
10
9
#[ derive( Clone ) ]
11
10
pub struct CratePatch {
12
- /// Crate name to patch
13
11
pub name : String ,
14
- /// URL of the git repo
15
12
pub uri : String ,
16
- /// Branch of the git repo
17
13
pub branch : String
18
14
}
19
15
@@ -43,25 +39,24 @@ impl<'a> Builder<'a> {
43
39
/// # Example
44
40
///
45
41
/// ```no_run
46
- /// # use rustwide::{WorkspaceBuilder, Toolchain, Crate, CratePatch, cmd::SandboxBuilder};
42
+ /// # use rustwide::{WorkspaceBuilder, Toolchain, Crate, cmd::SandboxBuilder};
47
43
/// # use std::error::Error;
48
44
/// # fn main() -> Result<(), Box<dyn Error>> {
49
45
/// # let workspace = WorkspaceBuilder::new("".as_ref(), "").init()?;
50
46
/// # let toolchain = Toolchain::Dist { name: "".into() };
51
47
/// # let krate = Crate::local("".as_ref());
52
48
/// # let sandbox = SandboxBuilder::new();
53
- /// let crate_patch = CratePatch { name: "bar".into(), uri: "https://github.com/foo/bar".into(), branch: "baz".into() };
54
49
/// let mut build_dir = workspace.build_dir("foo");
55
50
/// build_dir.build(&toolchain, &krate, sandbox)
56
- /// .patch(crate_patch )
51
+ /// .patch_with_git("bar".into(), "https://github.com/foo/bar".into(), "baz".into() )
57
52
/// .run(|build| {
58
53
/// build.cargo().args(&["test", "--all"]).run()?;
59
54
/// Ok(())
60
55
/// })?;
61
56
/// # Ok(())
62
57
/// # }
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 } ) ;
65
60
self
66
61
}
67
62
0 commit comments