For those of you following along with keyword generics in Rust, the current proposal is this [0]:
trait ?const ?async Read {
?const ?async fn read(&mut self, buf: &mut [u8]) -> Result<usize>;
?const ?async fn read_to_string(&mut self, buf: &mut String) -> Result<usize> { .. }
}
/// Read from a reader into a string.
?const ?async fn read_to_string(reader: &mut impl ?const ?async Read) -> io::Result<String> {
let mut string = String::new();
reader.read_to_string(&mut string).await?;
Ok(string)
}
which was rightfully disliked [1]. There have been some other proposals however, such as this one I wrote about [2] fn foo<F, T>(closure: F) -> Option<T>
where
F: FnMut(&T) -> bool,
effect
const if F: const,
?async,
{ /* ... */ }
for which someone made a more detailed issue [3]. It is similar to a `where` clause in that the `effect` clause comes afterwards and defines the effects that a function can have.[0] https://blog.rust-lang.org/inside-rust/2023/02/23/keyword-ge...
[1] https://old.reddit.com/r/rust/comments/119y8ex/keyword_gener...
[2] https://github.com/rust-lang/keyword-generics-initiative/iss...
[3] https://github.com/rust-lang/keyword-generics-initiative/iss...