INNER CODE UNIT · Rust

to_c_rect

elringus/sprite-dicing · crates/abi/src/lib.rs:199

fn to_c_rect(rect: &sprite_dicing::Rect) -> sd_rect {
    sd_rect {
        x: rect.x,
        y: rect.y,
        width: rect.width,
        height: rect.height,
    }
}

fn pixel_count(width: u32, height: u32) -> usize {
    width as usize * height as usize
}

unsafe fn to_slice<'a, T>(ptr: *const T, len: usize) -> Option<&'a [T]> {
    match (ptr.is_null(), len) {
        (_, 0) => Some(&[]),
        (true, _) => None,
        (false, _) => Some(slice::from_raw_parts(ptr, len)),

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…