From a171623c01b5994af050a53cf50c7afcd8a17f4a Mon Sep 17 00:00:00 2001
From: "iliya.saroukha" <iliya.saroukha@hes-so.ch>
Date: Fri, 10 Feb 2023 14:29:07 +0100
Subject: [PATCH] modified to pass by copy func signatures

---
 src/code_templates/mod.rs | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/code_templates/mod.rs b/src/code_templates/mod.rs
index 33d551f..4d17482 100644
--- a/src/code_templates/mod.rs
+++ b/src/code_templates/mod.rs
@@ -1,6 +1,6 @@
 use simplegen::CodeBuffer;
 
-pub fn template_for_header(filename: &mut String) -> CodeBuffer {
+pub fn template_for_header(mut filename: String) -> CodeBuffer {
     let mut buffer = CodeBuffer::new(4);
 
     // Removing extension from filename
@@ -21,7 +21,7 @@ pub fn template_for_header(filename: &mut String) -> CodeBuffer {
     return buffer;
 }
 
-pub fn template_for_implementation(hfile_name: &mut String) -> CodeBuffer {
+pub fn template_for_implementation(mut hfile_name: String) -> CodeBuffer {
     let mut buffer = CodeBuffer::new(4);
 
     for _ in 0..1 {
@@ -49,7 +49,7 @@ pub fn template_for_main(path_to_hfile: String) -> CodeBuffer {
     return buffer;
 }
 
-pub fn template_for_makefile_algo(hfile_name: &mut String, main_name: &mut String) -> CodeBuffer {
+pub fn template_for_makefile_algo(mut hfile_name: String, mut main_name: String) -> CodeBuffer {
     let mut buffer = CodeBuffer::new(4);
 
     // Removing extensions
@@ -60,7 +60,8 @@ pub fn template_for_makefile_algo(hfile_name: &mut String, main_name: &mut Strin
 
     buffer.println("# This file was automatically generated by `create-prog-app`");
     buffer.println("CC:=gcc");
-    buffer.println("CFLAGS:=-Wall -Wextra -g -pedantic -fsanitize=address -fsanitize=leak -lm");
+    buffer.println("CFLAGS:=-Wall -Wextra -g -pedantic -fsanitize=address -fsanitize=leak");
+    buffer.println("LIBS:=-lm");
     buffer.println("VPATH:=struct");
     buffer.println("# Due to the oddity of MAKE and the fact you cannot generate \"true\" tabs,");
     buffer.println("# the \"tab\" character is replaced by spaces.");
@@ -76,13 +77,13 @@ pub fn template_for_makefile_algo(hfile_name: &mut String, main_name: &mut Strin
         )
         .as_str(),
     );
-    buffer.println_right("$(CC) $(CFLAGS) $^ -o $@");
+    buffer.println_right("$(CC) $(CFLAGS) $(LIBS) $^ -o $@");
     buffer.println_left("");
     buffer.println(format!("{0}.o: {0}.c", main_name.to_lowercase()).as_str());
-    buffer.println_right("$(CC) $(CFLAGS) -c $<");
+    buffer.println_right("$(CC) $(CFLAGS) $(LIBS) -c $<");
     buffer.println_left("");
     buffer.println(format!("{0}.o: {0}.c {0}.h", hfile_name.to_lowercase()).as_str());
-    buffer.println_right("$(CC) $(CFLAGS) -c $<");
+    buffer.println_right("$(CC) $(CFLAGS) $(LIBS) -c $<");
     buffer.println_left("");
     buffer.println("clean:");
     buffer.println_right(format!("rm -f *.o {}", main_name.to_lowercase()).as_str());
-- 
GitLab