Can't move because lifetime enhanced type

Can not return/move because owned by the current function. Seems the lifetime is the problem, normally this should work.

The device_physical got a life time on it, like this: PhysicalDevice<'a> inside Vulkan struct. Aside of <'a> infesting all the way up to the top struct with its need to be defined. It also makes Arc<Instance> living shorter. I don't seem to find a way to add any 'a to Arch<Instance> to solve this problem. Nor can I remove the 'a for device_physical.

pub struct Vulkan<'a>
{
    instance: Arc<Instance>,
    device_physical: PhysicalDevice<'a>,
}

     pub fn new() -> Vulkan<'a>
            {
                let required_extensions = vulkano_win::required_extensions();
                let instance = Instance::new(None, &required_extensions, None).unwrap();
                let device_physical = PhysicalDevice::enumerate(&instance).next().unwrap();
            }

     Vulkan
            {
                instance,
                device_physical,
            }
        }

Isn't device_physical holding the borrow of instance? If so, you're creating a self-referential struct, which is impossible in safe Rust.

Ah, I didn't think of that, I was convinced my Rust was wrong. According to the source, yes, it does have a field named instance: &'a Arc<Instance> in it to begin with. This tells me that I'm using Vulkano the wrong way. I actually don't need to store Arc inside Vulkan struct.

It still won't build like this, but, I also noticed that device holds physical_device. Seems I need to write it out more.

Ash wasn't like this. I figure that's a result of Vulkano trying to make unsafe code safe, or something, anyways, thanks for the hint. This opens doors now.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.