Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

[HELP] Why is gdk::Atom::value() unsafe #564

Closed
psychon opened this issue Jun 6, 2021 · 2 comments · Fixed by #656
Closed

[HELP] Why is gdk::Atom::value() unsafe #564

psychon opened this issue Jun 6, 2021 · 2 comments · Fixed by #656
Milestone

Comments

@psychon
Copy link
Contributor

psychon commented Jun 6, 2021

As far as I can tell, this function just casts a number to another number.

gtk3-rs/gdk/src/atom.rs

Lines 47 to 49 in 69a4942

pub unsafe fn value(self) -> usize {
self.0 as usize
}

I am not quite sure what ffi::GdkAtom actually is, but it seems to be an integer cast to a pointer (???):

pub const NONE: Atom = Atom(0 as *mut _);

Thus, I would suggest to drop the unsafe from here:

pub unsafe fn value(self) -> usize {

@bilelmoussaoui
Copy link
Member

It probably shouldn't...the commit that added it doesn't mention the reasoning behind

@GuillaumeGomez
Copy link
Member

It was apparently because of a clippy lint. Might be worth giving it another try if the situation changed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants