• Psyhackological@lemmy.ml
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    2 months ago

    Wth is that, that is the most anti-idiomatic code I have ever seen

    pub fn get_cursor() -> ResultType<Option<u64>> {
        let mut res = None;
        DISPLAY.with(|conn| {
            if let Ok(d) = conn.try_borrow_mut() {
                if !d.is_null() {
                    unsafe {
                        let img = XFixesGetCursorImage(*d);
                        if !img.is_null() {
                            res = Some((*img).cursor_serial as u64);
                            XFree(img as _);
                        }
                    }
                }
            }
        });
        Ok(res)
    }
    

    I’m not an expert but this seems wrong.