Skip to content

Mark init function as unsafe#279

Open
kitcatier wants to merge 1 commit intoLea-fish:mainfrom
kitcatier:main
Open

Mark init function as unsafe#279
kitcatier wants to merge 1 commit intoLea-fish:mainfrom
kitcatier:main

Conversation

@kitcatier
Copy link

@kitcatier kitcatier commented Mar 20, 2023

Leafish/src/gl/mod.rs

Lines 25 to 29 in f44cf08

pub fn init(context: glow::Context) {
unsafe {
CONTEXT = Box::into_raw(Box::new(context));
}
}

Hello, it is not a good choice to mark the entire function body as unsafe, which will make the caller ignore the safety requirements that the function parameters must guarantee, the developer who calls the init function may not notice this safety requirement.
Marking them unsafe also means that callers must make sure they know what they're doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant