From 6a4b2e918ddc8d95dc96a8ab37fa04b0a524d4ec Mon Sep 17 00:00:00 2001 From: Avril Date: Thu, 20 Jan 2022 21:12:52 +0000 Subject: [PATCH] =?UTF-8?q?Fortune=20for=20parapop's=20current=20commit:?= =?UTF-8?q?=20Small=20curse=20=E2=88=92=20=E5=B0=8F=E5=87=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 5 +++++ src/iter.rs | 2 +- src/lib.rs | 13 ++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 45b5baa..3c3ff57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,4 +6,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] + [dependencies] + +[build-dependencies] +rustc_version = "0.2" diff --git a/src/iter.rs b/src/iter.rs index 1999265..13ed723 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -152,7 +152,7 @@ impl<'a, T> ExactSizeIterator for IntoIter<'a, T>{} #[derive(Debug)] struct FullIterRef<'a, T>(std::slice::Iter<'a, T>); -//struct PartialIterRef<'a, T>(&) +//struct PartialIterRef<'a, T>(&) //XXX: This probably isn't possible unless it takes an exclusive reference of Populator<'a, T>. Having to pass 'a around really sucks hey. impl<'a, T> Iterator for FullIterRef<'a, T> { diff --git a/src/lib.rs b/src/lib.rs index f5b6e00..9b3aad5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +//#![cfg_attr(all(nightly, feature="nightly"), feature(never_type))] #![allow(dead_code)] @@ -13,6 +14,14 @@ use std::ops::Drop; pub mod iter; +/* XXX: We don't need this. We can just use `()` +#[cfg(all(nightly, feature="nightly"))] +type Void = !; +#[cfg(not(all(nightly, feature="nightly")))] +type Void = std::convert::Infallible; +*/ + +/// Like PhantomData but for a lifetime. Essentially PhantomData &'a () #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Copy)] #[repr(transparent)] struct PhantomLifetime<'a>(std::marker::PhantomData<&'a ()>); @@ -157,6 +166,7 @@ impl<'a, T> Drop for Populator<'a, T> unsafe impl<'a, T: 'a> Send for Populator<'a, T> where Box: Send {} unsafe impl<'a, T: 'a> Sync for Populator<'a, T>{} // Populator is always sync +//TODO: Maybe add methods with Arc receivors? impl<'a, T> Populator<'a, T> { /// Checks if an item exists at this index exclusively. @@ -268,6 +278,7 @@ impl<'a, T> Populator<'a, T> idx } } + //TODO: get_excusive -> RefEx /// Try to get an exclusive, mutable reference to an item at `idx` if an item exists there. /// @@ -391,7 +402,7 @@ impl<'a, T: 'a> FromIterator> for Populator<'a, T> } } -impl<'a, T: 'a> IntoIterator for Populator<'a, T> // FUCK why do we need to make this 'static???? fuck this... dyn dispatch in rust is so jank. why can't we use 'a!!! +impl<'a, T: 'a> IntoIterator for Populator<'a, T> { type Item = T; type IntoIter = iter::IntoIter<'a, T>;