-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Currently, there is no unsafe
stopping someone from doing something like this:
let mut m1 = Mouse::new();
let mut m2 = Mouse::new();
// At the same time
m1.init();
m2.init();
Which would mess things up if the same ports are being accessed simultaneously.
I would suggest: making the init
function unsafe
:
/// # Safety
/// Reads and writes to ports 0x60 and 0x64. You must ensure that these ports are not being accessed concurrently by other code.
And another idea: What if the init
function (and the other functions such as was a standalone function instead of being a method of Mouse
? This way, we can leave Mouse
as a pure, safe parser for incoming mouse data while making it more obvious that the init
function modifies global state.
Metadata
Metadata
Assignees
Labels
No labels