Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unsafe globals #245

Closed
5 tasks done
zrzka opened this issue Sep 23, 2019 · 6 comments · Fixed by crossterm-rs/crossterm-utils#5
Closed
5 tasks done

Remove unsafe globals #245

zrzka opened this issue Sep 23, 2019 · 6 comments · Fixed by crossterm-rs/crossterm-utils#5

Comments

@zrzka
Copy link
Contributor

zrzka commented Sep 23, 2019

For example, Windows cursor implementation does use ...

static mut SAVED_CURSOR_POS: (u16, u16) = (0, 0);

... to store the cursor position, etc. We have to go through the code, check for other occurrences and fix them.

Occurences:

@TimonPost
Copy link
Member

TimonPost commented Sep 23, 2019

I actually had that in the past, I would not mind to change it back to lazy_static, I had that code because it would save me a dependency and terminals are single-threaded most of the cases anyways. So feel free to change that back.

@TimonPost
Copy link
Member

#248

@TimonPost TimonPost changed the title Remove unsafe & static mut Remove unsafe globals Sep 23, 2019
@zrzka
Copy link
Contributor Author

zrzka commented Sep 24, 2019

terminals are single-threaded most of the cases anyways

  • It breaks the Rust safety rule - aliasing & mutation should never happen at the same time if the mutation isn't synchronised.
  • Sharing mutable references in Rust is undefined behaviour.
  • Generally speaking, people always tend to talk about threads, but they should talk about concurrency and reentrance, because it can happen even without threads.

Can't find the issue now, but there's one about deprecation / removal of the static mut from the Rust language.

@MaulingMonkey
Copy link

Can't find the issue now, but there's one about deprecation / removal of the static mut from the Rust language.

rust-lang/rust#53639

@zrzka
Copy link
Contributor Author

zrzka commented Sep 26, 2019

Yep, this one exactly! Thanks :)

@TimonPost
Copy link
Member

It looks like all the unsafe statics are removed. This can be closed.

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

Successfully merging a pull request may close this issue.

3 participants