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

RFC - Allow Drop types in statics/const functions #1440

Merged
merged 7 commits into from
Apr 22, 2016
Merged
Prev Previous commit
Next Next commit
Update alternatives (UnsafeCell trick is a "bug", lazy_static uses ra…
…w pointers on stable)
  • Loading branch information
thepowersgang committed Jan 1, 2016
commit c886a0aed5e912d731d359876b937903e666456c
5 changes: 4 additions & 1 deletion text/0000-drop-types-in-const.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 32,10 @@ Destructors do not run on `static` items (by design), so this can lead to unexpe
# Alternatives
[alternatives]: #alternatives

Existing workarounds are based on storing `Option<T>`, and initialising it to `Some` upon first access. These solutions work, but require runtime intialisation and incur a checking overhead on subsequent accesses.
- Runtime initialisation of a raw pointer can be used instead (as the `lazy_static` crate currently does on stable)
- On nightly, a bug related to `static` and `UnsafeCell<Option<T>>` can be used to remove the dynamic allocation.

Both of these alternatives require runtime initialisation, and incur a checking overhead on subsequent accesses.

# Unresolved questions
[unresolved]: #unresolved-questions
Expand Down