Skip to content

Commit 44a041c

Browse files
asensio-projectphil-opp
authored andcommitted
Modify lifetimes in buffer and buffer_mut methods (#319)
1 parent d5dd05c commit 44a041c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

api/src/info.rs

+8
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,14 @@ impl FrameBuffer {
186186
unsafe { self.create_buffer_mut() }
187187
}
188188

189+
/// Converts the frame buffer to a raw byte slice.
190+
///
191+
/// The same as `buffer_mut()` but takes the ownership and returns the
192+
/// mutable buffer with a `'static` lifetime.
193+
pub fn into_buffer(self) -> &'static mut [u8] {
194+
unsafe { self.create_buffer_mut() }
195+
}
196+
189197
unsafe fn create_buffer<'a>(&self) -> &'a [u8] {
190198
unsafe { slice::from_raw_parts(self.buffer_start as *const u8, self.info.byte_len) }
191199
}

0 commit comments

Comments
 (0)