Skip to content

Commit 88ac58e

Browse files
authored
Merge pull request #221 from jehiggs/master
Clarify behavior of `expand`
2 parents 3ea767f + 8d0695d commit 88ac58e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,15 +662,26 @@ impl Config {
662662
/// This is only relevant for C and C++ files.
663663
///
664664
/// # Panics
665+
/// Panics if more than one file is present in the config, or if compiler
666+
/// path has an invalid file name.
665667
///
666-
/// Panics if compiler path has an invalid file name.
668+
/// # Example
669+
/// ```no_run
670+
/// let out = gcc::Config::new()
671+
/// .file("src/foo.c")
672+
/// .expand();
673+
/// ```
667674
pub fn expand(&self) -> Vec<u8> {
668675
let compiler = self.get_compiler();
669676
let mut cmd = compiler.to_command();
670677
for &(ref a, ref b) in self.env.iter() {
671678
cmd.env(a, b);
672679
}
673680
cmd.arg(compiler.family.expand_flag());
681+
682+
assert!(self.files.len() <= 1,
683+
"Expand may only be called for a single file");
684+
674685
for file in self.files.iter() {
675686
cmd.arg(file);
676687
}

0 commit comments

Comments
 (0)