[pve-devel] [PATCH installer v3 1/2] tui: bootdisk: refactor Rc<RefCell<..>> type into custom type
Christoph Heiss
c.heiss at proxmox.com
Thu Nov 9 10:40:55 CET 2023
Will be used/passed around quite a lot of times due to future changes,
so simplify it a bit.
No functional changes.
Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
proxmox-tui-installer/src/views/bootdisk.rs | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/proxmox-tui-installer/src/views/bootdisk.rs b/proxmox-tui-installer/src/views/bootdisk.rs
index 5272258..6309d74 100644
--- a/proxmox-tui-installer/src/views/bootdisk.rs
+++ b/proxmox-tui-installer/src/views/bootdisk.rs
@@ -29,9 +29,13 @@ use proxmox_installer_common::{
/// https://openzfs.github.io/openzfs-docs/Performance%20and%20Tuning/Module%20Parameters.html#zfs-arc-max
const ZFS_ARC_MIN_SIZE_MIB: usize = 64; // MiB
+/// Convience wrapper when needing to take a (interior-mutable) reference to `BootdiskOptions`.
+/// Interior mutability is safe for this case, as it is completely single-threaded.
+pub type BootdiskOptionsRef = Rc<RefCell<BootdiskOptions>>;
+
pub struct BootdiskOptionsView {
view: LinearLayout,
- advanced_options: Rc<RefCell<BootdiskOptions>>,
+ advanced_options: BootdiskOptionsRef,
boot_type: BootType,
}
@@ -616,17 +620,17 @@ impl ViewWrapper for ZfsBootdiskOptionsView {
fn advanced_options_view(
runinfo: &RuntimeInfo,
- options: Rc<RefCell<BootdiskOptions>>,
+ options_ref: BootdiskOptionsRef,
product_conf: ProductConfig,
) -> impl View {
Dialog::around(AdvancedBootdiskOptionsView::new(
runinfo,
- &(*options).borrow(),
+ &(*options_ref).borrow(),
product_conf,
))
.title("Advanced bootdisk options")
.button("Ok", {
- let options_ref = options.clone();
+ let options_ref = options_ref.clone();
move |siv| {
let options = siv
.call_on_name("advanced-bootdisk-options-dialog", |view: &mut Dialog| {
--
2.42.0
More information about the pve-devel
mailing list