drawing_gl 0.8.0

OpenGL backend for 2D graphics library
Documentation
1
2
3
4
5
6
7
8
9
10
use std::ffi::CString;

pub fn create_whitespace_cstring_with_len(len: usize) -> CString {
    // allocate buffer of correct size
    let mut buffer: Vec<u8> = Vec::with_capacity(len + 1);
    // fill it with len spaces
    buffer.extend([b' '].iter().cycle().take(len));
    // convert buffer to CString
    unsafe { CString::from_vec_unchecked(buffer) }
}