I know this is a Rust newbie problem, but I actually can't wrap my head around it. I need to pass around a PhysicalDevice from the Vulkano library. The problem is, PhysicalDevice holds a reference:
pub struct PhysicalDevice<'a> {
instance: &'a Arc<Instance>,
device: usize,
}
So Rust won't compile my sacred code:
struct InstanceInfo<'a> {
instance: Arc<Instance>,
physical: PhysicalDevice<'a>,
// ...
}
// ...
fn instantiate() -> InstanceInfo<'static> {
// ...
let instance = Instance::new(None, &required_extensions, None).unwrap();
let physical = PhysicalDevice::enumerate(&instance).next().unwrap();
// ...
InstanceInfo { // cannot return value referencing local blah
instance,
physical,
// ...
}
}
How can I work around this?