aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs2
-rw-r--r--src/makefile/mod.rs14
2 files changed, 8 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs
index e58188b..a78d9c1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -25,7 +25,7 @@ fn main() {
// TODO dump command-line args into MAKEFLAGS
// TODO dump command-line macros into environment
// TODO add SHELL macro
- let mut makefile = Makefile::new(args.clone());
+ let mut makefile = Makefile::new(&args);
for filename in &args.makefile {
if filename == &PathBuf::from("-") {
makefile.and_read(stdin().lock());
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs
index d55238e..dae742f 100644
--- a/src/makefile/mod.rs
+++ b/src/makefile/mod.rs
@@ -209,17 +209,17 @@ enum MacroSource {
Builtin,
}
-pub struct Makefile {
+pub struct Makefile<'a> {
inference_rules: Vec<InferenceRule>,
macros: HashMap<String, (MacroSource, TokenString)>,
targets: RefCell<HashMap<String, Rc<RefCell<Target>>>>,
pub first_non_special_target: Option<String>,
- args: Args,
+ args: &'a Args,
// TODO borrow warnings from Python version
}
-impl Makefile {
- pub fn new(args: Args) -> Makefile {
+impl<'a> Makefile<'a> {
+ pub fn new(args: &'a Args) -> Self {
let mut inference_rules = vec![];
let mut macros = HashMap::new();
let mut targets = HashMap::new();
@@ -264,7 +264,7 @@ impl Makefile {
}
}
- pub fn and_read_file(&mut self, path: impl AsRef<Path>) -> &mut Makefile {
+ pub fn and_read_file(&mut self, path: impl AsRef<Path>) -> &mut Self {
let file = File::open(path);
// TODO handle errors
let file = file.expect("couldn't open makefile!");
@@ -272,7 +272,7 @@ impl Makefile {
self.and_read(file_reader)
}
- pub fn and_read(&mut self, source: impl BufRead) -> &mut Makefile {
+ pub fn and_read(&mut self, source: impl BufRead) -> &mut Self {
let mut lines_iter = source.lines().enumerate().peekable();
while let Some((line_number, line)) = lines_iter.next() {
// TODO handle I/O errors at all
@@ -754,7 +754,7 @@ impl Makefile {
}
}
-impl fmt::Display for Makefile {
+impl fmt::Display for Makefile<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let header = |f: &mut fmt::Formatter, t: &str| {
writeln!(f, "{}\n{:=^width$}", t, "", width = t.len())