lending_iterator/
_lib.rs

1/*!
2[`windows_mut()`]: windows_mut()
3[HKT!]: higher_kinded_types::HKT!
4[higher-kinded]: higher_kinded_types
5[`lending_iterator::adapters`]: lending_iterator::adapters
6*/
7#![cfg_attr(feature = "better-docs",
8    cfg_attr(all(), doc = include_str!("../README.md")),
9    feature(doc_cfg, doc_notable_trait),
10    // for macro_vis
11    feature(decl_macro, rustc_attrs),
12)]
13#![no_std]
14#![forbid(unsafe_code)]
15#![allow(nonstandard_style, uncommon_codepoints)]
16
17#[macro_use]
18mod utils;
19
20#[doc(inline)]
21pub use self::{
22    lending_iterator::{
23        LendingIterator,
24        constructors::{
25            FromFn,
26            from_fn,
27            from_iter,
28            repeat_mut,
29            windows_mut_::windows_mut,
30        },
31    },
32};
33
34/// <code>[#\[::nougat::gat\]]</code>
35///
36/// [#\[::nougat::gat\]]: https://docs.rs/nougat/~0.2.4/nougat/attr.gat.html
37///
38/// Using this attribute is needed when implementing `LendingIterator` for your
39/// own types, as well as **for reëxporting the `LendingIterator` trait**,
40/// itself, in a way that remains compatible with further downstream
41/// implementations down the line: `#[gat(Item)] use …::LendingIterator;`.
42///
43///   - See the documentation of <code>[#\[::nougat::gat\]]</code> for more info
44///     about this.
45pub use ::nou::gat;
46
47/// <code>[#\[::macro_rules_attribute::apply\]]</code>
48///
49/// [#\[::macro_rules_attribute::apply\]]: https://docs.rs/macro_rules_attribute/~0.1.2/macro_rules_attribute/attr.apply.html
50///
51/// Using this in conjunction with [`Gat!`] to get access to expressing
52/// `LendingIterator<Item<…> = …>` kind of trait bounds on the annotated item.
53///
54///   - See the documentation of
55///     <code>[#\[::macro_rules_attribute::apply\]]</code> for more info
56///     about this.
57pub use ::macro_rules_attribute::apply;
58
59/// <code>[::nougat::Gat!]</code>
60///
61/// [::nougat::Gat!]: https://docs.rs/nougat/~0.2.4/nougat/macro.Gat.html
62///
63/// You can use this macro around a type to get access to:
64///
65///   - `<I as LendingIterator>::Item<'lt>` (if for some reason you did not
66///     like <code>[Item]\<\'lt, I\></code>);
67///
68///   - `impl for<'n> LendingIterator<Item<'n> = …>`.
69///
70/// [Item]: crate::lending_iterator::Item
71///
72/// You can also use it in conjunction with <code>#\[[apply]\]</code>, as in
73/// <code>#\[[apply]\([Gat!]\)\]</code>, to annotate an item with it so as to:
74///
75///   - get the previous functionality applied to all types occurrences in that
76///     annotated item;
77///
78///   - get `LendingIterator<Item<'…> = …>` kind of trait bounds (_e.g._, as a
79///     in `I : …` clauses, or as a super trait) to also work anywhere on the
80///     annotated item (this is something no _targeted_ macro could ever
81///     support, due to language limitations).
82///
83/// ## Example
84///
85/**  - ```rust
86    use ::lending_iterator::prelude::*;
87
88    #[apply(Gat!)]
89    fn my_iter_1<T> (slice: &'_ mut [T])
90      -> impl '_ + for<'n> LendingIterator<Item<'n> = &'n mut [T; 2]>
91    {
92        windows_mut::<T, 2>(slice)
93    }
94    // same as:
95    fn my_iter_2<T> (slice: &'_ mut [T])
96      -> Gat!(impl '_ + for<'n> LendingIterator<Item<'n> = &'n mut [T; 2]>)
97    {
98        windows_mut::<T, 2>(slice)
99    }
100
101    #[apply(Gat!)]
102    fn print_all<I, T> (mut iter: I)
103    where
104        T : ::core::fmt::Debug,
105        // Trait bound on GAT
106        for<'n>
107            <I as LendingIterator>::Item<'n> : Send
108        ,
109        // Equality constraint on GAT
110        I : for<'n> LendingIterator<Item<'n> = &'n mut [T; 2]>,
111    {
112        iter.for_each(|&mut [ref x, ref y]| {
113            dbg!(x, y);
114        });
115    }
116    ``` */
117///
118/// ___
119///
120///   - See the documentation of <code>[::nougat::Gat!]</code> for more info
121///     about this.
122pub use ::nou::Gat;
123
124#[doc(inline)]
125#[apply(cfg_futures)]
126pub use self::lending_iterator::constructors::from_stream;
127
128#[cfg(feature = "alloc")]
129extern crate alloc;
130
131#[macro_use]
132extern crate extension_traits;
133
134#[macro_use]
135extern crate macro_rules_attribute;
136
137extern crate nougat as nou;
138
139#[macro_use]
140extern crate polonius_the_crab;
141
142pub
143mod higher_kinded_types;
144
145#[path = "lending_iterator/_mod.rs"]
146pub
147mod lending_iterator;
148
149/// The crate's prelude.
150pub
151mod prelude;
152
153// macro internals
154#[doc(hidden)] /** Not part of the public API */ pub
155mod ඞ {
156    pub use {
157        ::core::{ // or `std`
158            self,
159        },
160        ::lending_iterator_proc_macros::{
161            self,
162        },
163    };
164}
165
166#[doc(hidden)] /** Not part of the public API */ pub
167enum HKT<T : ?Sized> {
168    HKT,
169    _ඞ((
170        ::never_say_never::Never,
171        ::core::marker::PhantomData<T>,
172    )),
173}
174#[doc(hidden)] /** Not part of the public API */ pub
175use HKT::*;
176
177#[cfg_attr(feature = "ui-tests",
178    cfg_attr(all(), doc = include_str!("compile_fail_tests.md")),
179)]
180mod _compile_fail_tests {}