mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
remove unused code and allow dead code
This commit is contained in:
parent
fe4bc7274a
commit
14c46374fa
|
@ -2,6 +2,7 @@ pub struct Singleton<T> {
|
|||
single: Option<T>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl<T> Singleton<T> {
|
||||
pub const fn new(s: T) -> Self {
|
||||
Singleton { single: Some(s) }
|
||||
|
@ -13,39 +14,4 @@ impl<T> Singleton<T> {
|
|||
let g = core::mem::replace(&mut self.single, None);
|
||||
g.unwrap()
|
||||
}
|
||||
|
||||
pub fn ret(&mut self, ret: T) {
|
||||
self.single = Some(ret);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Single {
|
||||
is_taken: bool,
|
||||
}
|
||||
|
||||
pub struct SingleToken<'a> {
|
||||
cell: &'a mut bool,
|
||||
}
|
||||
|
||||
impl Single {
|
||||
pub const fn new() -> Self {
|
||||
Single { is_taken: false }
|
||||
}
|
||||
|
||||
pub fn take(&mut self) -> Result<SingleToken, &'static str> {
|
||||
if self.is_taken {
|
||||
Err("Already taken")
|
||||
} else {
|
||||
self.is_taken = true;
|
||||
Ok(SingleToken {
|
||||
cell: &mut self.is_taken,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for SingleToken<'_> {
|
||||
fn drop(&mut self) {
|
||||
(*self.cell) = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue