The error E0382 occurs because options.prefs is a Vec<(String, Pref)>, and Rust's ownership rules prevent you from using a value after it has been moved. In this case, options.prefs is moved on line 300, and you're trying to use it again on line 310.
options.prefs to a function or method, Rust moves the value by default if the type does not implement the Copy trait (which Vec does not).Copy Trait: Vec<(String, Pref)> does not implement Copy, so it cannot be implicitly copied.If you need to use options.prefs multiple times, clone it before moving it:
rusthandler.prepare( &profile, options.args, options.env.unwrap_or_default(), options.prefs.clone(), // Clone the value )?; // Now you can still use `options.prefs` later.
If the function accepts a reference, pass a reference instead of moving the value:
rusthandler.prepare( &profile, options.args, options.env.unwrap_or_default(), &options.prefs, // Pass a reference )?;
Note: This only works if handler.prepare accepts a reference (e.g., &Vec<(String, Pref)>).
If possible, restructure your code to avoid moving options.prefs until you're done using it. For example:
rustlet prefs = options.prefs; // Move it once handler.prepare(&profile, options.args, options.env.unwrap_or_default(), prefs)?; // No further use of `options.prefs` after this point.
Rc or Arc for Shared OwnershipIf you need shared ownership, wrap options.prefs in an Rc (single-threaded) or Arc (multi-threaded):
rustuse std::sync::Arc; let prefs = Arc::new(options.prefs); handler.prepare(&profile, options.args, options.env.unwrap_or_default(), Arc::clone(&prefs))?; // You can still use `prefs` elsewhere.
In most cases, cloning (options.prefs.clone()) is the simplest fix if you need to use the value again. If performance is a concern, consider borrowing or restructuring your code.
Vibe can make mistakes. Check answers. Learn more