Help understanding how trait bounds work

Just a slightly alternate take.

  1. You might want the argument to be independent of SourceFile in which case;
    fn new<S: io::Read>(source: S)
  2. This makes the function not generic over structure so leads to confusion when in generic impl struct; Could either make it a totally free function or just use some Dummy.
impl SourceFile<std::io::Empty> {
    fn new<S: io::Read>(source: S) -> SourceFile<impl io::Read> {
1 Like