aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/main.rs b/src/main.rs
index 3890ae9..2deced8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -92,19 +92,19 @@ fn main() -> Result<()> {
92 .find_map(|(k,v)| if k == "path" { Some(v.clone()) } else { None }) 92 .find_map(|(k,v)| if k == "path" { Some(v.clone()) } else { None })
93 .unwrap_or(String::from("")); 93 .unwrap_or(String::from(""));
94 key.push_str(&attr.0); 94 key.push_str(&attr.0);
95 /* Insert (or replace) block of code. 95 /* Insert (or replace) block of code. */
96 * NOTE: we are always "borrowing" the snippets of code with `Cow`, i.e., it 96 if attr.1.iter().any(|c| c == "override") {
97 * will always be a `Cow::Borrowed` value, until we process the string 97 blocks.insert(key, Cow::from(code));
98 * substituting macros. */ 98 } else {
99 //blocks.insert(key, Cow::from(code)); 99 blocks.entry(key)
100 blocks.entry(key) 100 .and_modify(|s| {
101 .and_modify(|s| { 101 let mut concat = s.to_string();
102 let mut concat = s.to_string(); 102 concat.push_str("\n");
103 concat.push_str("\n"); 103 concat.push_str(code);
104 concat.push_str(code); 104 *s = Cow::from(concat);
105 *s = Cow::from(concat); 105 })
106 }) 106 .or_insert(Cow::from(code));
107 .or_insert(Cow::from(code)); 107 }
108 } else { 108 } else {
109 // println!("The following code has no ID:"); 109 // println!("The following code has no ID:");
110 // code.lines().for_each(|l| println!(" {}", l)); 110 // code.lines().for_each(|l| println!(" {}", l));