Use function and trait attributes to make a function/trait have effect-like behaviour
instead of adding new syntax. There's still some new syntax in trait bounds, but these are
removed by the attribute at attribute expansion time.
This is experimentally being built with a proc macro in https://github.com/yoshuawuyts/maybe-async-channel.
#![allow(unused)]fnmain() {
/// A trimmed-down version of the `std::Iterator` trait.pubtraitIterator {
typeItem;
fnnext(&mutself) -> Option<Self::Item>;
fnsize_hint(&self) -> (usize, Option<usize>);
}
/// An adaptation of `Iterator::find` to a free-functionpubfnfind<I, T, P>(iter: &mut I, predicate: P) -> Option<T>
where
I: Iterator<Item = T> + Sized,
P: FnMut(&T) -> bool;
}