use interior mutability for SourceFile lines

Using shared ownership for these may or may not have been a mistake in
the first place. We'll find out.
This commit is contained in:
Qyriad 2026-01-28 14:31:34 +01:00
parent e5d0bdf0c0
commit 34a9c3f864
3 changed files with 136 additions and 15 deletions

View file

@ -35,10 +35,25 @@ fn main_wrapped() -> Result<(), Box<dyn StdError + Send + Sync + 'static>> {
.custom_flags(libc::O_CLOEXEC);
let source_file = SourceFile::open_from(Arc::clone(&def_path), opts)?;
let last_def_line = append_override::get_highest_prio(&args.name, source_file)?;
let last_def_line = append_override::get_highest_prio(&args.name, source_file.clone())?;
let pri: i64 = {
let text = last_def_line.text();
let pat = "lib.mkOverride (";
let start = text.find(pat).unwrap();
let substr = &text[start..];
let substr = substr.strip_prefix(pat).unwrap();
let end_paren = substr.find(")").unwrap();
let final_num = &substr[..end_paren];
final_num.parse().unwrap()
};
eprintln!("{last_def_line}");
dbg!(&pri);
append_override::write_next_prio(source_file, last_def_line, pri, pri - 1)?;
Ok(())
}