mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 00:01:34 +11:00
Also add default implementation for InitOnce
This commit is contained in:
parent
661eb7155f
commit
42eadde631
|
@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- An abstraction over hblank DMA to allow for cool effects like gradients and circular windows. See the dma_effect* examples.
|
||||
- Expermental and incomplete support for MIDI files with agb-tracker.
|
||||
- Fixnum now implements [`num::Num`](https://docs.rs/num/0.4/num/trait.Num.html) from the [`num`](https://crates.io/crates/num) crate.
|
||||
- `Default` implementations for `RandomNumberGenerator` and `RawMutex`.
|
||||
- `Default` implementations for `RandomNumberGenerator`, `InitOnce` and `RawMutex`.
|
||||
|
||||
### Change
|
||||
- A few functions which previously accepted a `Vector<u16>` now accept an `impl Into<Vector2D<u16>>` instead.
|
||||
|
|
|
@ -142,6 +142,7 @@ pub struct InitOnce<T> {
|
|||
is_initialized: Static<bool>,
|
||||
value: UnsafeCell<MaybeUninit<T>>,
|
||||
}
|
||||
|
||||
impl<T> InitOnce<T> {
|
||||
/// Creates a new uninitialized object.
|
||||
#[must_use]
|
||||
|
@ -201,6 +202,13 @@ impl<T> InitOnce<T> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Default for InitOnce<T> {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Drop for InitOnce<T> {
|
||||
fn drop(&mut self) {
|
||||
if self.is_initialized.read() {
|
||||
|
|
Loading…
Reference in a new issue