I'm new to rust and I'm trying to return a Window
struct:
pub struct Window<'a> {
ev_loop: EventLoop<()>,
window_builder: WindowBuilder,
context_builder: ContextBuilder<'a, NotCurrent>,
display: Display
}
from this function:
pub fn init_lib () -> Window<'static> {
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new();
let display = glium::Display::new(wb, cb, &event_loop).unwrap();
return Window {
ev_loop: event_loop,
window_builder: wb,
context_builder: cb,
display: display
}
}
however whilst returning wb
as window_builder
and cb
as context_builder
I get the following error:
use of moved value: `cb`
value used here after moverustcE0382
lib.rs(32, 43): value moved here
lib.rs(31, 9): move occurs because `cb` has type `ContextBuilder<'_, NotCurrent>`, which does not implement the `Copy` trait
I'm using glium
which is a library, so I can't just modify the library code. How can I fix this?