Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Stream is a struct (a type with named fields). It has three parameters, the lifetime s, the type S and the type A. S must satisfy the Seed trait, and A must satisfy the Copy trait. Stream has two fields, next and seed. The type of next is a Box (basically an owned pointer into the heap) of a type that implements the Fn(S) -> Step<S, A> interface (that is, it can be called with an S as the single argument and produces something of the type Step parametrized with S and A) and does not outlive the s lifetime. The field seed is of the type S.

This chapter of the book is probably a good start:

https://doc.rust-lang.org/book/ch10-00-generics.html



Small typo:

it can be called with an S as the single argument and produces something of the type Step parametrized with S and A) and -does not- outlives the s lifetime.

's refers to a minimal lifetime and not a maximal limit.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: