From 0f3ebbfff9f9626d5a532d63e06a430cbce17407 Mon Sep 17 00:00:00 2001 From: Daniel Henry-Mantilla Date: Thu, 21 Jul 2022 12:31:26 +0200 Subject: [PATCH 1/9] Further move the badges --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8ab53b5..59edf2d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # `::lending-iterator` -Fully generic `LendingIterator`s in stable Rust. - [![Repository](https://img.shields.io/badge/repository-GitHub-brightgreen.svg)]( https://github.com/danielhenrymantilla/lending-iterator.rs) [![Latest version](https://img.shields.io/crates/v/lending-iterator.svg)]( @@ -19,6 +17,8 @@ https://github.com/danielhenrymantilla/lending-iterator.rs/actions) +Fully generic `LendingIterator`s in stable Rust. + - this pattern used to be called `StreamingIterator`, but since [`Stream`]( https://docs.rs/futures/0.3.21/futures/stream/trait.Stream.html)s entered the picture (as the `async/.await` version of `Iterator`s, that is, From 5b97e60d5926aff6e2549227f08fc56d09e746c2 Mon Sep 17 00:00:00 2001 From: Daniel Henry-Mantilla Date: Thu, 21 Jul 2022 12:32:50 +0200 Subject: [PATCH 2/9] Add keywords --- Cargo.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 69a155b..594c1af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,13 @@ readme = "README.md" rust-version = "1.57.0" description = "Fully general lending iterators in stable rust: windows_mut!" -keywords = ["rust-patterns"] +keywords = [ + "streaming", + "streaming-iterator", + "windows_mut", + "hkt", + "gat", +] [features] default = [ From 763adfa64ac9a3eb387d153535c4dbc3763f9c3e Mon Sep 17 00:00:00 2001 From: Daniel Henry-Mantilla Date: Thu, 21 Jul 2022 14:40:37 +0200 Subject: [PATCH 3/9] README doc nits --- README.md | 9 +++++---- src/higher_kinded_types.md | 2 +- src/lending_iterator/_mod.rs | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 59edf2d..82a13ad 100644 --- a/README.md +++ b/README.md @@ -145,10 +145,10 @@ fn slice_sort_by_key ( ) where Key : HKT, // "Key : <'_>" - for<'any> - A!(Key<'any>) : Ord + KeyGetter : for<'item> FnMut(&'item Item) -> A!(Key<'item>), + for<'item> + A!(Key<'item>) : Ord , - KeyGetter : FnMut(&Item) -> A!(Key<'_>), { slice.sort_by(|a, b| Ord::cmp( &get_key(a), @@ -160,7 +160,8 @@ where struct Client { key: String, version: u8 } -fn main() { +fn main () +{ let clients: &mut [Client] = &mut []; // Error: cannot infer an appropriate lifetime for autoref due to conflicting requirements diff --git a/src/higher_kinded_types.md b/src/higher_kinded_types.md index 98c3697..fe765cd 100644 --- a/src/higher_kinded_types.md +++ b/src/higher_kinded_types.md @@ -804,7 +804,7 @@ fn main () RefCell::new(Person { name: "".into(), surname: "Globby".into(), - age: 255, + age: 0xff, }), ]; let elems = &array[..]; diff --git a/src/lending_iterator/_mod.rs b/src/lending_iterator/_mod.rs index 8a70dc5..71f504e 100644 --- a/src/lending_iterator/_mod.rs +++ b/src/lending_iterator/_mod.rs @@ -178,7 +178,7 @@ type Item<'lt, I : LendingIterator> = /// It does come with a few caveats, though: **the `LendingIterator::Item` item /// is no longer really nameable**, at least not _directly_. /// -/// - The current implementation of [`::nougat]` uses a helper _higher-order_ +/// - The current implementation of [`::nougat`] uses a helper _higher-order_ /// super-trait, called /// for\<\'any\> [LendingIteratorඞItem]\<\'any\>, which has, /// itself, a non-generic associated type, `::T`. That way, @@ -187,13 +187,13 @@ type Item<'lt, I : LendingIterator> = /// /// **BUT THIS MAY change within semver-compatible changes of `nougat`** /// -/// Thence why that path should never be used, directly, by downstream code. +/// That's why that path should never be used, directly, by downstream code. /// /// The only reason I am even talking about it and not having it /// `#[doc(hidden)]` is that exposing it makes understanding the signatures /// of the adapters multiple order of magnitude easier. /// -/// Thence the following "rules": +/// Hence the following "rules": /// /// - Use [Item]\<\'_, I\> instead of `I::Item<'_>`. /// From 3720183a71ec74cda555535a2ab26d3030b18a0a Mon Sep 17 00:00:00 2001 From: Daniel Henry-Mantilla Date: Thu, 21 Jul 2022 14:43:04 +0200 Subject: [PATCH 4/9] [doc] Make `details/summary` items way more visible / eye-catching --- README.md | 4 +- fix-docsrs-li-details-summary.html | 62 ++++++++++++++++++++++++++- src/higher_kinded_types.md | 14 +++--- src/lending_iterator/_mod.rs | 2 +- src/lending_iterator/adapters/_mod.rs | 2 +- 5 files changed, 72 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 82a13ad..a57eb7c 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Fully generic `LendingIterator`s in stable Rust. ## Examples -
Click to hide +
Click to seeClick to hide ### `windows_mut()`! @@ -134,7 +134,7 @@ As noted in this **6-year-old issue**: Such an API can easily be provided using the HKT API of this crate: -
Click to see +
Click to seeClick to hide ```rust use ::lending_iterator::higher_kinded_types::{*, Apply as A}; diff --git a/fix-docsrs-li-details-summary.html b/fix-docsrs-li-details-summary.html index ccf4892..4b33f82 100644 --- a/fix-docsrs-li-details-summary.html +++ b/fix-docsrs-li-details-summary.html @@ -1,5 +1,65 @@ diff --git a/src/higher_kinded_types.md b/src/higher_kinded_types.md index fe765cd..6365fd7 100644 --- a/src/higher_kinded_types.md +++ b/src/higher_kinded_types.md @@ -7,7 +7,7 @@ ### What are Higher-Kinded Types? -
Click to see +
Click to seeClick to hide A higher-kinded type is an actual / **full / standalone** type which is, itself, "generic", or rather, to which we can further feed generic parameters (such as @@ -99,11 +99,11 @@ HKTs come into play the moment we need "generic generics". ### Why? What are Higher-Kinded Types _for_? -
Click to see +
Click to seeClick to hide - #### Type-HKTs -
Click to see +
Click to seeClick to hide Consider the following pseudo-code: @@ -172,7 +172,7 @@ HKTs come into play the moment we need "generic generics". - #### Lifetime HKTs -
Click to hide +
Click to seeClick to hide Another use case can be around lifetimes, when dealing with higher-order lifetimes (_e.g._, when exposing borrows of callee local variables to a @@ -442,7 +442,7 @@ HKTs come into play the moment we need "generic generics". ### How? → Back to real Rust -
Click to see +
Click to seeClick to hide This, in real Rust, comes with three challenges: @@ -626,7 +626,7 @@ trait HKT = for<'any> WithLifetime<'any>; ## The three important things to remember when working with these HKT APIs -
Click to hide +
Click to seeClick to hide 1. **APIs use `T : HKT` to express `T : <'lt>`** @@ -735,7 +735,7 @@ trait HKT = for<'any> WithLifetime<'any>; ## Illustration: fully working code for the `debug_each` example -
Click to see +
Click to seeClick to hide ```rust #![forbid(unsafe_code)] diff --git a/src/lending_iterator/_mod.rs b/src/lending_iterator/_mod.rs index 71f504e..1801eac 100644 --- a/src/lending_iterator/_mod.rs +++ b/src/lending_iterator/_mod.rs @@ -91,7 +91,7 @@ type Item<'lt, I : LendingIterator> = /// type of the `fn next(&'_ mut self)` method being allowed to depend on that /// `'_`**. /// -///
Click to hide +///
Click to seeClick to hide /// /// - That type is called the `Item<'_>` type, and is a /// [`generic_associated_type`](#a-generic-associated-type). diff --git a/src/lending_iterator/adapters/_mod.rs b/src/lending_iterator/adapters/_mod.rs index 5d97664..66758c5 100644 --- a/src/lending_iterator/adapters/_mod.rs +++ b/src/lending_iterator/adapters/_mod.rs @@ -2,7 +2,7 @@ //! //! # Example //! -//!
Click to hide +//!
Click to seeClick to hide //! /*! - ```rust use ::lending_iterator::prelude::*; From 3737d3fbcc593b3ca834f756ecc32ba12c50d19f Mon Sep 17 00:00:00 2001 From: Daniel Henry-Mantilla Date: Thu, 21 Jul 2022 14:44:41 +0200 Subject: [PATCH 5/9] Version bump: release candidate --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- src/proc_macros/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a769998..7a9f21c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "lending-iterator" -version = "0.1.2" +version = "0.1.3-rc1" dependencies = [ "extension-traits", "futures", @@ -136,7 +136,7 @@ dependencies = [ [[package]] name = "lending-iterator-proc_macros" -version = "0.1.2" +version = "0.1.3-rc1" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 594c1af..0e2e6f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ name = "lending-iterator" authors = [ "Daniel Henry-Mantilla ", ] -version = "0.1.2" # Keep in sync +version = "0.1.3-rc1" # Keep in sync edition = "2021" license = "Zlib OR MIT OR Apache-2.0" @@ -56,7 +56,7 @@ macro-vis.version = "0.1.1" [dependencies.lending-iterator-proc_macros] path = "src/proc_macros" -version = "0.1.2" # Keep in sync +version = "0.1.3-rc1" # Keep in sync [dev-dependencies] diff --git a/src/proc_macros/Cargo.toml b/src/proc_macros/Cargo.toml index cb55cfc..e9397db 100644 --- a/src/proc_macros/Cargo.toml +++ b/src/proc_macros/Cargo.toml @@ -8,7 +8,7 @@ name = "lending-iterator-proc_macros" authors = [ "Daniel Henry-Mantilla " ] -version = "0.1.2" # Keep in sync +version = "0.1.3-rc1" # Keep in sync edition = "2021" license = "Zlib OR MIT OR Apache-2.0" From c0212881936792597b30d2db21f4dcdacfff691f Mon Sep 17 00:00:00 2001 From: Daniel Henry-Mantilla Date: Thu, 21 Jul 2022 15:25:56 +0200 Subject: [PATCH 6/9] Simplify some code --- src/lending_iterator/_mod.rs | 46 +++++++++++-------------- src/lending_iterator/adapters/filter.rs | 10 +----- 2 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/lending_iterator/_mod.rs b/src/lending_iterator/_mod.rs index 1801eac..0920257 100644 --- a/src/lending_iterator/_mod.rs +++ b/src/lending_iterator/_mod.rs @@ -659,6 +659,7 @@ where /// /// [Box]: ::alloc::boxed::Box /// [CanonicalHKT]: crate::prelude::CanonicalHKT + #[apply(cfg_alloc)] fn dyn_boxed_auto (self: Self) -> BoxedDynLendingIterator where @@ -670,34 +671,27 @@ where )} macro_rules! pervasive_hkt_choices {( - $( - ($map:ident, $Map:ident)( - $( - $(#[$attr:meta])* - $fname:ident: [$($R:tt)*], $HKT:ty, -> $Ret:ty, - )* - ), - )* -) => ( - $( + ($map:ident, $Map:ident)( $( - $(#[$attr])* - fn $fname<$($R)*, F> ( - self: Self, - f: F, - ) -> $Map - where - for<'any> - F : FnMut( - [&'any Self; 0], - Item<'any, Self>, - ) -> $Ret - , - Self : Sized, - { - self.$map::<$HKT, F>(f) - } + $(#[$attr:meta])* + $fname:ident: [$($R:tt)*], $HKT:ty, -> $Ret:ty, )* + ) $(,)? +) => ( + $( + $(#[$attr])* + fn $fname<$($R)*, F> ( + self: Self, + f: F, + ) -> $Map + where + for<'any> + F : FnMut([&'any Self; 0], Item<'any, Self>) -> $Ret + , + Self : Sized, + { + self.$map::<$HKT, F>(f) + } )* )} use pervasive_hkt_choices; diff --git a/src/lending_iterator/adapters/filter.rs b/src/lending_iterator/adapters/filter.rs index 8ad0534..c07404c 100644 --- a/src/lending_iterator/adapters/filter.rs +++ b/src/lending_iterator/adapters/filter.rs @@ -31,14 +31,6 @@ where self: &'_ mut Filter, ) -> Option> { - use ::polonius_the_crab::prelude::*; - let mut iter = &mut self.iter; - polonius_loop!(|iter| -> Option> { - let ret = iter.next(); - if matches!(ret, Some(ref it) if (self.should_yield)(it).not()) { - polonius_continue!(); - } - polonius_return!(ret); - }) + self.iter.find(&mut self.should_yield) } } From 6490dcaca3a78bec3cf3ec0fc2802e10ec15270f Mon Sep 17 00:00:00 2001 From: Daniel Henry-Mantilla Date: Thu, 21 Jul 2022 15:26:13 +0200 Subject: [PATCH 7/9] Version 0.1.3 release --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- src/proc_macros/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a9f21c..39aa228 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "lending-iterator" -version = "0.1.3-rc1" +version = "0.1.3" dependencies = [ "extension-traits", "futures", @@ -136,7 +136,7 @@ dependencies = [ [[package]] name = "lending-iterator-proc_macros" -version = "0.1.3-rc1" +version = "0.1.3" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 0e2e6f9..4f914ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ name = "lending-iterator" authors = [ "Daniel Henry-Mantilla ", ] -version = "0.1.3-rc1" # Keep in sync +version = "0.1.3" # Keep in sync edition = "2021" license = "Zlib OR MIT OR Apache-2.0" @@ -56,7 +56,7 @@ macro-vis.version = "0.1.1" [dependencies.lending-iterator-proc_macros] path = "src/proc_macros" -version = "0.1.3-rc1" # Keep in sync +version = "0.1.3" # Keep in sync [dev-dependencies] diff --git a/src/proc_macros/Cargo.toml b/src/proc_macros/Cargo.toml index e9397db..da14e25 100644 --- a/src/proc_macros/Cargo.toml +++ b/src/proc_macros/Cargo.toml @@ -8,7 +8,7 @@ name = "lending-iterator-proc_macros" authors = [ "Daniel Henry-Mantilla " ] -version = "0.1.3-rc1" # Keep in sync +version = "0.1.3" # Keep in sync edition = "2021" license = "Zlib OR MIT OR Apache-2.0" From 68fb86e7689d822da2b6dfed5e10e1aeaba5bfc0 Mon Sep 17 00:00:00 2001 From: Daniel Henry-Mantilla Date: Thu, 21 Jul 2022 15:28:08 +0200 Subject: [PATCH 8/9] Remove extraneous `bacon.toml` file --- bacon.toml | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 bacon.toml diff --git a/bacon.toml b/bacon.toml deleted file mode 100644 index 76bc25d..0000000 --- a/bacon.toml +++ /dev/null @@ -1,23 +0,0 @@ - -# This is a configuration file for the bacon tool -# More info at https://github.com/Canop/bacon - -default_job = "check" - -[jobs] - -[jobs.check] -command = ["cargo", "check", "--tests", "--color", "always"] -need_stdout = false - -[jobs.light] -command = ["cargo", "check", "--color", "always"] -need_stdout = false - -[jobs.clippy] -command = ["cargo", "clippy", "--color", "always"] -need_stdout = false - -[jobs.test] -command = ["cargo", "test", "--color", "always"] -need_stdout = true From dac9433bc363fb1fe16a1de95f0bcb3bdd45b448 Mon Sep 17 00:00:00 2001 From: Daniel Henry-Mantilla Date: Thu, 21 Jul 2022 15:30:51 +0200 Subject: [PATCH 9/9] Disable toggling see-hide messages for Github's README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a57eb7c..082bdc8 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Fully generic `LendingIterator`s in stable Rust. ## Examples -
Click to seeClick to hide +
Click to see/hide ### `windows_mut()`! @@ -134,7 +134,7 @@ As noted in this **6-year-old issue**: Such an API can easily be provided using the HKT API of this crate: -
Click to seeClick to hide +
Click to see/hide ```rust use ::lending_iterator::higher_kinded_types::{*, Apply as A};