Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/DutchGhost/maybeuninit
MaybeUninit in Zig.
https://github.com/DutchGhost/maybeuninit
maybeuninit zig
Last synced: 2 months ago
JSON representation
MaybeUninit in Zig.
- Host: GitHub
- URL: https://github.com/DutchGhost/maybeuninit
- Owner: DutchGhost
- License: eupl-1.2
- Created: 2019-08-10T18:43:02.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-30T19:13:21.000Z (over 4 years ago)
- Last Synced: 2024-10-16T19:21:32.878Z (3 months ago)
- Topics: maybeuninit, zig
- Language: Zig
- Size: 30.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-zig - DutchGhost/maybeuninit
README
# maybeuninit
[![License:EUPL](https://img.shields.io/badge/License-EUPLv.1.2-brightgreen.svg)](https://opensource.org/licenses/EUPL-1.2)
![Zig](https://github.com/DutchGhost/maybeuninit/workflows/Zig/badge.svg?branch=master)This is a userlevel implementation of the `undefined` keyword in Zig.
It is inspired by [MaybeUninit](https://doc.rust-lang.org/stable/core/mem/union.MaybeUninit.html) in Rust.
## Minimum supported `Zig`
`master`Each day will be tested in CI whether this project still builds on Zig master.
## Recent changes
* 0.6.1
* Add `withByte` as initializer function.
* Remove all use of `inline`, as the usage of `inline` was considered wrong.
* 0.6
* Rename `assume_init` to `assumeInit`.
* rename `as_ptr` and `as_mut_ptr` to `asPtr` and `asMutPtr`.
* rename `first_ptr` and `first_ptr_mut` to `firstPtr` and `firstPtrMut`.
* 0.5.2
* Only support Zig's Master branch.
* 0.5.1
* Add a private constant uninit intializer, to get around https://github.com/ziglang/zig/issues/3994.
* 0.5
* Do not call `@memset` in `MaybeUninit(T).zeroed()` if `T` has a size of 0.
* 0.4
* Prevent `MaybeUninit(noreturn)` from being created. See https://github.com/ziglang/zig/issues/3603.
* 0.3
* Change the return type of `first_ptr_mut` from `*Self` to `*T`.
* Adds a test that calls `first_ptr_mut` on an empty slice.
* 0.2
* Change the definition of `MaybeUninit` from `packed union` to `extern union`, due to `packed union`'s setting the alignment always to 1.
* 0.1
* Initial library setup.## Issues
At the point of writing, it is impossible to create an uninitialized `MaybeUninit(T)`, and later initialize it at compiletime.
This is an issue of the compiler, which tracks the current active field of packed and extern unions when used at compiletime, while it shouldn't.
The issue is reported to the Zig compiler, and can be followed [here](https://github.com/ziglang/zig/issues/3134).