Open ccclement opened 3 years ago
This may not be possible to implement since the underlying library creates Format objects via the Workbook object so the interface would have to be something like:
let mut format2 = workbook.clone(format1);
Which unfortunately isn't very Rust like.
you might be able to implement the actual attachment to the workbook via closure, which would allow Rust to treat it as a separate object. Would require a rewrite of the Format struct though, I think...
Would require a rewrite of the Format struct though, I think...
Probably, and that is unlikely to happen in the C library because the workbook management/coupling design is too tight. Format cloning is supported in the pure Rust version however since I went with a decoupled design to avoid borrow/owner issues.
I just looked into it more and it seems like Format is getting detached from the workbooks in 0.6 with Format::new()! So our problem is getting solved!
I had another idea for doing this: We could try implementing Copy/Clone by attaching a Clone of the item directly to the parent workbook with a trait. That would mean not being able to clone it across workbooks tho
Is it possible to copy or clone a format to avoid code repetition?