mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
docs(test): Document main_file function
This commit is contained in:
parent
170756601c
commit
c9dddd27c8
@ -540,10 +540,24 @@ pub fn project_in_home(name: &str) -> ProjectBuilder {
|
||||
|
||||
// === Helpers ===
|
||||
|
||||
pub fn main_file(println: &str, deps: &[&str]) -> String {
|
||||
/// Generate a `main.rs` printing the specified text
|
||||
///
|
||||
/// ```rust
|
||||
/// # use cargo_test_support::main_file;
|
||||
/// # mod dep {
|
||||
/// # fn bar() -> &'static str {
|
||||
/// # "world"
|
||||
/// # }
|
||||
/// # }
|
||||
/// main_file(
|
||||
/// r#""hello {}", dep::bar()"#,
|
||||
/// &[]
|
||||
/// );
|
||||
/// ```
|
||||
pub fn main_file(println: &str, externed_deps: &[&str]) -> String {
|
||||
let mut buf = String::new();
|
||||
|
||||
for dep in deps.iter() {
|
||||
for dep in externed_deps.iter() {
|
||||
buf.push_str(&format!("extern crate {};\n", dep));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user