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>;