Skip to main content

parse

Function parse 

Source
pub fn parse<I, S>(args: I) -> Result<Info, ParseError>
where I: IntoIterator<Item = S>, S: AsRef<str>,
Expand description

Parses an iterator of strings into an Info struct.

This function handles the standard RUSTC_WRAPPER invocation format: <wrapper> - <rustc> <args...>.

Examples found in repository?
examples/basic.rs (line 24)
3fn main() {
4    // Example invocation via Cargo's RUSTC_WRAPPER protocol
5    let args = vec![
6        "wrapc",
7        "-",
8        "rustc",
9        "--crate-name=my_crate",
10        "--edition=2021",
11        "-L",
12        "native=/usr/lib",
13        "-l",
14        "static:+bundle,+whole-archive=mylib:renamed_lib",
15        "--emit=link,dep-info=/tmp/dep.d",
16        "-C",
17        "opt-level=3",
18        "-Clink-arg=-fuse-ld=lld",
19        "src/main.rs",
20        "-o",
21        "sth.exe",
22    ];
23
24    let info: Info = parse(&args).expect("Failed to parse arguments");
25
26    println!("{:?}", info);
27
28    // Reconstruct args accurately for rustc execution
29    let reconstructed = info.to_args();
30    println!("\nReconstructed arguments: {:?}", reconstructed);
31}