How do I make a structure generic in Rust without higher kinded type (HKT) support?
问题 I am trying to make the Iteratee structure generic so I can pass in a different parsing function and get an different Iteratee . This is the non-generic version that works: use std::io::{BufRead, BufReader}; use std::str::{from_utf8, Utf8Error}; #[derive(PartialEq, Debug)] struct Cat<'a> { name: &'a str, } fn parse<'a>(slice: &'a [u8]) -> Result<Cat<'a>, Utf8Error> { from_utf8(slice).map(|name| Cat { name: name }) } struct Iteratee<R> where R: BufRead + Sized { read: R, } impl<R> Iteratee<R>