- 
                Notifications
    You must be signed in to change notification settings 
- Fork 42
Closed
Description
The signature of Device::from_native does not constrain the relationship between the lifetimes of its input parameters and the lifetime of its return value, which may result in dangling references.
For example:
let mut custom = CustomDevice(...);
let device = Device::from_native(&mut custom);
drop(custom);
// Here `device` still holds a pointer to `custom`One solution is to add a PhantomData containing NativeDevice to the Device to inform the compiler of the implicit lifetime requirements here.
struct Device<D> {
    // ...
    phantom: std::marker::PhantomData<D>,
}Metadata
Metadata
Assignees
Labels
No labels